orders 相关问题

仅用于电子商务的相关问题。不要在所有其他情况下使用。

获取 WooCommerce 中的处理状态订单计数?

我想获取 WooCommerce 中的处理订单计数。我在代码片段插件中使用以下代码,但它有效。 if( !function_exists( 'wc_processing_order_count' ) ) {

回答 5 投票 0

将产品图片添加到 Woocommerce 我的帐户订单视图

我想在 Woocommerce 的帐户查看订单页面上添加图像。我能够获取图像,但尺寸太大,我不知道需要在哪里添加此代码: 我想在 Woocommerce 的帐户查看订单页面上添加图像。我能够获取图像,但尺寸太大,我不知道需要在哪里添加此代码: <?php // Get a list of all items that belong to the order $products = $order->get_items(); // Loop through the items and get the product image foreach( $products as $product ) { $product_obj = new WC_Product( $product["product_id"] ); echo $product_obj->get_image(); } ?> 任何帮助将不胜感激 这是查看订单页面上的位置,我想在其中添加产品图片: 下面的挂钩函数将完成这项工作(您可能需要添加一些CSS样式规则): // Display the product thumbnail in order view pages add_filter( 'woocommerce_order_item_name', 'display_product_image_in_order_item', 20, 3 ); function display_product_image_in_order_item( $item_name, $item, $is_visible ) { // Targeting view order pages only if( is_wc_endpoint_url( 'view-order' ) ) { $product = $item->get_product(); // Get the WC_Product object (from order item) $thumbnail = $product->get_image(array( 36, 36)); // Get the product thumbnail (from product object) if( $product->get_image_id() > 0 ) $item_name = '<div class="item-thumbnail">' . $thumbnail . '</div>' . $item_name; } return $item_name; } 代码位于活动子主题(或活动主题)的 function.php 文件中。已测试并有效。 注意 WC_Product 方法 get_image() 在内部使用 Wordpress get_the_post_thumbnail()。 更新:在代码中添加了if( $product->get_image_id() > 0 ),仅当产品图片存在时才显示产品图片。 您不需要获取主图像,只需通过 get_the_post_thumbnail() 获取缩略图即可: <?php // Get a list of all items that belong to the order $products = $order->get_items(); // Loop through the items and get the product image foreach( $products as $product ) { $product_obj = new WC_Product( $product["product_id"] ); echo get_the_post_thumbnail(); } ?> 写在 woocommerce/template/order/ordr-details-item.php 上 echo '<div class="product-imgae">'.$product->get_image(array( 80, 80)).'</div>'; 这将为您提供 80x80 尺寸的图像,根据您的需要进行更改。 我知道这个主题更多的是产品图片,但我如何上传产品变体的客户特定徽标,因为他还没有准备好上传。我根据产品页面的功能和逻辑制作的上传和预览。但现在我缺少更新不完整订单的部分。 我确实尝试过这段代码: add_filter('woocommerce_order_item_meta_end', '_hook_order_detail_item', 30, 3); function _hook_order_detail_item($item_id, $item, $order) { foreach ($order->get_items() as $inner_item) { if ($inner_item['_img_file_degree']&&$item_id===$inner_item->get_id()) { $_img_file = $inner_item['_img_file']; $_img_file_title = $_img_file[0]['title']; //print_r($_img_file_title); //$order_id = $order->get_order_number();$cart_items = $order->get_items( apply_filters( 'woocommerce_purchase_order_item_types', 'line_item' ) ); //echo '<pre>Hallo<br />'; print_r($cart_items);echo '<br /></pre>'; echo '<ul class="wc-item-meta" style="list-style: none; padding-left: 0; font-size: inherit;"><li><strong class="wc-item-meta-label">' . esc_html__('Bild hochgeladen:', 'woocommerce') . '</strong><span>' . $_img_file_title . '</span></li><li><strong class="wc-item-meta-label">' . esc_html__("Logo-Bilddrehung:", "woocommerce") . '</strong><span>' . $inner_item['_img_file_degree'] . '</span></li></ul>'; } elseif (is_wc_endpoint_url( 'view-order' )) { $order_id = $order->get_order_number();$cart_items = $order->get_items( apply_filters( 'woocommerce_purchase_order_item_types', 'line_item' ) ); $items = $order->get_items(); foreach ( $items as $item ) { $product_name = $item->get_name(); $product_id = $item->get_product_id(); $product_variation_id = $item->get_variation_id(); }; ?><form class="variations_form" method="post"><?php display_additional_product_fields(); // echo '<pre>Hallo<br />'; print_r($product_variation_id);echo '<br /></pre>'; ?><button type="submit" class="button" name="update_product" id="image_variant_upload" value="<?php esc_attr_e( 'Update product', 'woocommerce' ); ?>"><?php esc_html_e( 'Update product', 'woocommerce' ); ?> </button> <input type="hidden" name="product_id" value="<?php echo $product_id; ?>"> <input type="hidden" name="variation_id" class="variation_id" value="<?php echo $product_variation_id; ?>"> </form><?php if(array_key_exists('update_product', $_POST)) {add_custom_fields_data_as_custom_cart_item_data($cart_item, $product_id);}; ); }; } } 此代码与 add_action 位于同一文件中,用于在购物车上添加徽标作为产品变体图像上传。 我几个月前添加了这段代码,它运行得很好。唯一的问题是,当我删除产品时似乎会产生问题。如果产品被删除,当我进入帐户的订单历史记录页面时,会产生致命错误。这个问题可以解决吗?

回答 5 投票 0

就 Woocommerce 中取消的订单向客户发送电子邮件

我正在尝试在订单取消时向客户发送电子邮件。默认情况下,woocommerce 仅将此电子邮件发送给网站管理员。 此代码解决了相关帖子的问题...

回答 2 投票 0

获取用户最新的 WooCommerce 订单 ID,以便将其与联系表 7 一起使用

在我的网站上,当有人订购特定产品时,他会被重定向(使用产品数据中的“谢谢您 URL”字段)到客户必须填写表格的页面(使用 Contac...

回答 1 投票 0

根据订单付款方式突出显示 WooCommerce 管理订单列表

我正在寻找一种根据订单付款方式突出显示管理订单列表行的方法。 (专门针对 COD - 货到付款) 基于订购时突出显示 Woocommerce 管理订单列表

回答 2 投票 0

Django:celery 任务不使用 .delay() 执行

我正在使用“Django 2 by Examples”书中的代码示例来构建我的电子商务商店。视图按其应有的方式工作,但任务永远不会执行。没有错误。页面冻结在“哇...

回答 4 投票 0

在管理订单列表中显示按状态分组的客户订单数量

我正在使用在 WooCommerce 管理订单列表中添加一列的代码,该列显示特定订单状态的客户订单。 问题是有时当我刷新订单页面时会出现一些问题

回答 1 投票 0

显示旧订单数量的代码有问题

我正在使用创建一列的代码来显示用户是否有具有某些状态的旧订单。 问题是,有时当我刷新订单页面时会发生一些事情,它给了我 10/15/3...

回答 1 投票 0

WooCommerce 根据付款方式、送货方式和送货国家/地区添加自定义电子邮件内容

我想根据客户选择的运输方式向他们发送自定义文本电子邮件。我们使用运输区域。 爱沙尼亚 - “本地取货” - 订单上的“custom_text_1”

回答 1 投票 0

WooCommerce 根据付款方式和运输方式添加自定义电子邮件内容

我正在尝试根据付款方式和运输方式的组合向 woocommerce 完成的订单电子邮件通知添加不同的内容。 到目前为止我的代码: // 完成订单电子邮件

回答 1 投票 0

根据运输方式不同的已完成订单电子邮件 - WooCommerce 8.3.1

我想根据客户选择的运输方式向他们发送自定义文本电子邮件。我们使用运输区域。 爱沙尼亚 - “本地取货” - 订单上的“custom_text_1”

回答 1 投票 0

在 WooCommerce 订单快速视图中显示订单总额

我想在订单预览弹出窗口中显示订单总数,如下图所示。

回答 1 投票 0

在 Woocommerce 管理订单预览中显示订单总额

我想在订单预览弹出窗口中显示订单总数,如下图所示。

回答 1 投票 0

列出所有 WooCommerce 处理订单中的产品及其数量、SKU 和品牌

我有这段代码,可以在 WordPress 管理中创建一个页面,显示正在处理订单的产品。 函数register_pending_order_summary_page() { add_submenu_page( 'woocommerce', 'P...

回答 1 投票 0

在 WooCommerce 管理订单列表的自定义列中显示私人和客户管理注释

基于 LoicTheAzec 对在 WooCommerce 我的帐户订单列表中发送给客户的添加管理订单备注的回答 这是我尝试在

回答 2 投票 0

创建 Woocommerce 我的帐户订单页面,仅显示已完成的订单

我删除了之前的问题,因为我的措辞不好。我正在尝试创建一个仅显示已完成订单的 Woocommerce 我的帐户订单页面。我已经尝试过以下代码,但是......

回答 1 投票 0

WooCommerce 中的自定义订单搜索 SQL 查询速度慢

在一个大约有1万个订单的网站上,我们的订单搜索在搜索订单号时平均需要20秒才能完成。这是慢的 sql 查询 选择不同的 p1.post_id 来自

回答 1 投票 0

WooCommerce 虚拟产品 - 付款后自动完成订单

我有虚拟产品,我希望在购买时自动完成它们。 我发现下面粘贴的代码,将其添加到functions.php中,它确实有效,但有一个警告: 当人们选择...

回答 1 投票 0

WooCommerce 虚拟产品 - 付款后自动完成订单

我有虚拟产品,我希望在购买时自动完成它们。 我发现下面粘贴的代码,将其添加到functions.php中,它确实有效,但有一个警告: 当人们选择...

回答 1 投票 0

有效地更改 WooCommerce 订单总额,而不是使用 set_total 方法

我的客户可以通过商店信用(保存为用户数据)部分或全部支付订单。 如果店铺信用足以支付整个订单,顾客只能选择店铺

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.