cart

Rest API to store products in cart based on the user id in woocommerce

风流意气都作罢 提交于 2020-06-09 05:14:05
问题 Only related reference for the same I found with accepted by few people is the below mentioned code but there is no session stored in options table with the following key '_wc_session_'.$user_id function add_products_programmatically($user_id) { // Get the current session data and saved cart $wc_session_data = get_option('_wc_session_'.$user_id); // Get the persistent cart $full_user_meta = get_user_meta($user_id,'_woocommerce_persistent_cart', true); // Create a new WC_Cart instance and add

Woocommerce login redirect if cart not empty

扶醉桌前 提交于 2020-06-04 03:15:53
问题 I want to redirect the user to cart page after he logs in if the cart is not empty. I am trying this: function woocommerce_custom_redirects() { if(!WC()->cart->is_empty() ) wp_redirect( "https://edkasa.com/checkout" ); } add_action('wp_login', 'woocommerce_custom_redirects'); But this is not working, I am using buddypress plugin, any idea where am I going wrong. 回答1: With the wp_redirect() Function, it is suggested to follow that up with an explicit call to exit . For further Information on

Woocommerce login redirect if cart not empty

安稳与你 提交于 2020-06-04 03:15:28
问题 I want to redirect the user to cart page after he logs in if the cart is not empty. I am trying this: function woocommerce_custom_redirects() { if(!WC()->cart->is_empty() ) wp_redirect( "https://edkasa.com/checkout" ); } add_action('wp_login', 'woocommerce_custom_redirects'); But this is not working, I am using buddypress plugin, any idea where am I going wrong. 回答1: With the wp_redirect() Function, it is suggested to follow that up with an explicit call to exit . For further Information on

Woocommerce login redirect if cart not empty

房东的猫 提交于 2020-06-04 03:13:23
问题 I want to redirect the user to cart page after he logs in if the cart is not empty. I am trying this: function woocommerce_custom_redirects() { if(!WC()->cart->is_empty() ) wp_redirect( "https://edkasa.com/checkout" ); } add_action('wp_login', 'woocommerce_custom_redirects'); But this is not working, I am using buddypress plugin, any idea where am I going wrong. 回答1: With the wp_redirect() Function, it is suggested to follow that up with an explicit call to exit . For further Information on

Woocommerce login redirect if cart not empty

烈酒焚心 提交于 2020-06-04 03:13:03
问题 I want to redirect the user to cart page after he logs in if the cart is not empty. I am trying this: function woocommerce_custom_redirects() { if(!WC()->cart->is_empty() ) wp_redirect( "https://edkasa.com/checkout" ); } add_action('wp_login', 'woocommerce_custom_redirects'); But this is not working, I am using buddypress plugin, any idea where am I going wrong. 回答1: With the wp_redirect() Function, it is suggested to follow that up with an explicit call to exit . For further Information on

Change shipping class based on cart items shipping class count in Woocommerce

孤街浪徒 提交于 2020-05-29 06:47:26
问题 I'm having trouble with the default WooCommerce shipping class settings. We have a small webshop with 2 shipping costs. One for products that fit in the mailbox, and other that don't. We would like to make a setting that if there are 2 products with mailbox shipping class, than the price becomes a package price. Now on default WooCommerce only charges 1x the mailbox shipping class. 回答1: First you will need to make your shipping settings as in the below screen, for "Flat rate" shipping method

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

那年仲夏 提交于 2020-05-27 12:43:13
问题 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' )

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' )

Display the weight of cart and order items in WooCommerce

ε祈祈猫儿з 提交于 2020-05-26 08:04:13
问题 How can I to put the weight of each item under your description on the cart page and the payment page in woocommerce? Any advice is welcome. 回答1: 2020 Updated The following code will display the subtotal item weight for cart and order items everywhere: // Display the cart item weight in cart and checkout pages add_filter( 'woocommerce_get_item_data', 'display_custom_item_data', 10, 2 ); function display_custom_item_data( $cart_item_data, $cart_item ) { if ( $cart_item['data']->get_weight() >

Display the weight of cart and order items in WooCommerce

元气小坏坏 提交于 2020-05-26 08:03:53
问题 How can I to put the weight of each item under your description on the cart page and the payment page in woocommerce? Any advice is welcome. 回答1: 2020 Updated The following code will display the subtotal item weight for cart and order items everywhere: // Display the cart item weight in cart and checkout pages add_filter( 'woocommerce_get_item_data', 'display_custom_item_data', 10, 2 ); function display_custom_item_data( $cart_item_data, $cart_item ) { if ( $cart_item['data']->get_weight() >