shipping

Woocommerce change the shipping cost related with the subtotal

倖福魔咒の 提交于 2021-02-08 10:00:35
问题 I would like to know how can i change the shipping cost for example: If subtotal is lower than 10€ then shipping cost is 4.5€ if subtotal is same or higher than 10€ then make the shipping cost 2.5€ 回答1: The right way of doing it is like this: add_filter( 'woocommerce_package_rates', 'woocommerce_package_rates', 10, 2 ); function woocommerce_package_rates( $rates, $package ) { $new_cost = ( WC()->cart->subtotal < 10 ) ? 4.5 : 2.5; foreach($rates as $key => $rate ) { $rates[$key]->cost = $new

Charge a conditional Delivery fee in WooCommerce 3

一世执手 提交于 2021-02-08 09:01:05
问题 This is my condition like: If subtotal <= certain amount && subtotal <= certain amount So if the subtotal matches this criteria then I want to charge a delivery fee which should also show in the email invoice. Currently this is my code: add_action( 'woocommerce_cart_calculate_fees','my_delivery_fee' ); function my_delivery_fee() { global $woocommerce; if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return; $subtotal = $woocommerce->cart->subtotal; if(subtotal <= certain amount && subtotal <=

Shipping options depending on cart weight and shipping class

会有一股神秘感。 提交于 2021-02-08 07:51:19
问题 I am working on a WordPress site that uses WooCommerce. I found this piece of code that allows me to set a freight shipping option based on weight. It worked great until the client also wanted the same freight shipping option if a freight shipping class is selected on a product. add_filter( 'woocommerce_package_rates', 'bbloomer_woocommerce_tiered_shipping', 10, 2 ); function bbloomer_woocommerce_tiered_shipping( $rates, $package ) { if ( WC()->cart->cart_contents_weight < 300 ) { if ( isset(

Shipping options depending on cart weight and shipping class

蓝咒 提交于 2021-02-08 07:51:18
问题 I am working on a WordPress site that uses WooCommerce. I found this piece of code that allows me to set a freight shipping option based on weight. It worked great until the client also wanted the same freight shipping option if a freight shipping class is selected on a product. add_filter( 'woocommerce_package_rates', 'bbloomer_woocommerce_tiered_shipping', 10, 2 ); function bbloomer_woocommerce_tiered_shipping( $rates, $package ) { if ( WC()->cart->cart_contents_weight < 300 ) { if ( isset(

Shipping options depending on cart weight and shipping class

随声附和 提交于 2021-02-08 07:51:05
问题 I am working on a WordPress site that uses WooCommerce. I found this piece of code that allows me to set a freight shipping option based on weight. It worked great until the client also wanted the same freight shipping option if a freight shipping class is selected on a product. add_filter( 'woocommerce_package_rates', 'bbloomer_woocommerce_tiered_shipping', 10, 2 ); function bbloomer_woocommerce_tiered_shipping( $rates, $package ) { if ( WC()->cart->cart_contents_weight < 300 ) { if ( isset(

Shipping options depending on cart weight and shipping class

眉间皱痕 提交于 2021-02-08 07:50:32
问题 I am working on a WordPress site that uses WooCommerce. I found this piece of code that allows me to set a freight shipping option based on weight. It worked great until the client also wanted the same freight shipping option if a freight shipping class is selected on a product. add_filter( 'woocommerce_package_rates', 'bbloomer_woocommerce_tiered_shipping', 10, 2 ); function bbloomer_woocommerce_tiered_shipping( $rates, $package ) { if ( WC()->cart->cart_contents_weight < 300 ) { if ( isset(

Add a Woocommerce fee based on shipping class and item quantity

纵然是瞬间 提交于 2021-02-08 05:47:42
问题 In Woocommerce I am trying to add a shipping fee if a cart item has a specific shipping class assigned to the related product. I would like this shipping fee to be multiplied by the cart item quantity… I have this working when a product is added to the cart and the quantity is increased and the additional shipping fee is increased also. However if I add another product with the same shipping class and increase the quantity the additional fee does not increase. This is my code: // Add

Add a Woocommerce fee based on shipping class and item quantity

穿精又带淫゛_ 提交于 2021-02-08 05:47:00
问题 In Woocommerce I am trying to add a shipping fee if a cart item has a specific shipping class assigned to the related product. I would like this shipping fee to be multiplied by the cart item quantity… I have this working when a product is added to the cart and the quantity is increased and the additional shipping fee is increased also. However if I add another product with the same shipping class and increase the quantity the additional fee does not increase. This is my code: // Add

Set “flat rate” shipping method as default in woocommerce

本秂侑毒 提交于 2021-02-05 11:12:24
问题 I have a woocommerce website and I have set 2 shipping methods: - Flat Rate - Local pickup I would like to set the "Flat rate" shipping method as default (selected) in the cart or checkout page. Any help should be appreciated. 回答1: 1) You can use the following code (to set "flat rate" shipping method as default) In cart page: add_action( 'woocommerce_before_cart', 'set_default_chosen_shipping_method', 5 ); function set_default_chosen_shipping_method(){ // if( count( WC()->session->get(

Set “flat rate” shipping method as default in woocommerce

僤鯓⒐⒋嵵緔 提交于 2021-02-05 11:10:23
问题 I have a woocommerce website and I have set 2 shipping methods: - Flat Rate - Local pickup I would like to set the "Flat rate" shipping method as default (selected) in the cart or checkout page. Any help should be appreciated. 回答1: 1) You can use the following code (to set "flat rate" shipping method as default) In cart page: add_action( 'woocommerce_before_cart', 'set_default_chosen_shipping_method', 5 ); function set_default_chosen_shipping_method(){ // if( count( WC()->session->get(