hook-woocommerce

Sort products at the bottom of the product list in cart WooCommerce by product ID

こ雲淡風輕ζ 提交于 2020-05-27 12:42:05
问题 In WooCommerce, I use a code that auto adds packaging when adding any dish to the cart. The functionality is as follows: dish is in the shopping cart, 1 lunch box is added dishes are in the shopping cart, 2 lunch boxes are added dishes are in the shopping cart, 3 lunch boxes are added There are 3 lunch boxes, so now 1 package is added function add_delivery_charge_to_cart( $cart ) { if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return; if ( did_action( 'woocommerce_before_calculate_totals' )

How to display the product weight in kg, if more than 1000 grams

旧巷老猫 提交于 2020-05-17 07:41:28
问题 In Storefront theme, I use the code below that change the formatted weight from 1000g to 1kg: add_action('woocommerce_after_shop_loop_item_title', 'show_weight', 10); function show_weight() { global $product; $attributes = $product->get_attributes(); if ($product->has_weight()) { $weight = $product->get_weight(); $weight_unit = 'grams'; if ($weight >= 1000) { $weight = round(($weight / 1000), 2); $weight_unit = 'kg'; } print '<p>Weight: ' . $weight . ' ' . $weight_unit . '</p>'; } } How to

Catalogue mode for variable products based on geolocation in Woocommerce

我的未来我决定 提交于 2020-05-17 06:23:26
问题 I am trying to enable catalogue mode for a WooCommerce shop for users located everywhere but Australia. The store has 2 types of products simple variable I have tried "Turn Woocommerce shop into catalog for geolocated countries?" answer code, and it works well for "simple" products The issue is that variable products still show the quantity field and add to cart button although they are not purchasable. My understanding is that catalogue mode is essentially making products non purchasable. If

How to conditionally change WooCommerce billing address title if no separate shipping address is entered

China☆狼群 提交于 2020-05-16 22:01:12
问题 My site has two options you can ship to the billing address you can enter a billing address and a separate delivery address, pretty standard. If you enter both a billing and a shipping address during checkout, then in the order details page in My Account you can see both Billing address and Shipping address titles above the relevant addresses. If you only enter a billing address during checkout, in the order details page in My Account you can only see 'Billing' address, the address isn't

Prevent User Role from changing woocommerce order status

纵饮孤独 提交于 2020-05-16 07:48:05
问题 We would like to prevent shop manager from changing order status, we found a help here in the link below Restrict user role to change only some order statuses in Woocommerce But the issue here that it limits certain role ( shop Manager ) to some order statuses, we need to deny the shop manager from changing the order status completely not limit it to some order statuses. Also the snippet we mentioned remove the the order statuses from the bulk action drop down & the order details here: https:

Change user role if checkout custom checkbox is checked in WooCommerce

*爱你&永不变心* 提交于 2020-05-15 10:24:25
问题 I'm trying to add a custom function to my child-themes functions.php file where a checkbox is added to the bottom of the billing details form on the checkout page. This checkbox asks the customer if they'd like to become a wholesale customer. function customise_checkout_field_with_wholesale_option($checkout) { echo '<div id="wholesale_checkbox_wrap">'; woocommerce_form_field('wholesale_checkbox', array( 'type' => 'checkbox', 'class' => array('input-checkbox'), 'label' => __('Would you like to

If order has products on backorder - Split order and create new backorder from original

依然范特西╮ 提交于 2020-05-14 12:32:35
问题 I have the custom order status and it works. What I need help with here is looping through the order items and checking if any of them are on backorder and if so, take the backorder items out of the original order and create a new order and give the new order the Backorder status. The idea is to create the backorder if and only if there are items on backorder in the original order. add_action( 'woocommerce_checkout_order_processed', 'split_order_if_order_has_backorder_products', 10, 1 );

Display the weight of each cart items in WooCommerce

笑着哭i 提交于 2020-05-11 03:52:07
问题 I'm using Woocommerce and I'm trying to display the product weight for each product on cart page. I have used this: add_action('woocommerce_cart_collaterals', 'myprefix_cart_extra_info'); function myprefix_cart_extra_info() { global $woocommerce; echo '<div class="cart-extra-info">'; echo '<p class="total-weight">' . __('Total Weight:', 'woocommerce'); echo ' ' . $woocommerce->cart->cart_contents_weight . ' ' . get_option('woocommerce_weight_unit'); echo '</p>'; echo '</div>'; } It display

Display the weight of each cart items in WooCommerce

被刻印的时光 ゝ 提交于 2020-05-11 03:51:20
问题 I'm using Woocommerce and I'm trying to display the product weight for each product on cart page. I have used this: add_action('woocommerce_cart_collaterals', 'myprefix_cart_extra_info'); function myprefix_cart_extra_info() { global $woocommerce; echo '<div class="cart-extra-info">'; echo '<p class="total-weight">' . __('Total Weight:', 'woocommerce'); echo ' ' . $woocommerce->cart->cart_contents_weight . ' ' . get_option('woocommerce_weight_unit'); echo '</p>'; echo '</div>'; } It display

Get the order ID in checkout page before payment process

落爺英雄遲暮 提交于 2020-04-28 08:17:40
问题 In WooCommerce, I need to get order ID right in checkout page of WooCoommerce, before payment, when the order is created. I look at all sessions and tried to find out when order goes for payment in order_awaiting_payment session, but I need it before going for payment. So I think about a solution that is make order when checkout page loaded (In fact make it ready for payment) and when checkout real complete update it. How to get order ID in checkout page before order go for payment in