cart

Set a minimum order amount in WooCommerce

北慕城南 提交于 2020-05-23 07:22:51
问题 I want to have a minimum order amount in my WooCommerce store. The following code is perfectly showing a notice if the amount isn't reached but the checkout is still possible. How to disable checkout-button when the minimum amount isn't reached? add_action( 'woocommerce_checkout_process', 'wc_minimum_order_amount' ); add_action( 'woocommerce_before_cart' , 'wc_minimum_order_amount' ); function wc_minimum_order_amount() { // Set this variable to specify a minimum order value $minimum = 50; if

Disable Woocommerce cart line item quantity price calculation

◇◆丶佛笑我妖孽 提交于 2020-05-14 11:04:32
问题 I am looking for function that can disable the quantity x item price in the cart page. Normally if product price is €1 and quantity is 3 | Line item subtotal is €3 … (1€ x 3) . Now I Would like to keep the product price without x quantity calculation like this: Product price is €1 and quantity is 3 | Line item subtotal is €1 Does anybody a idea how to disable this quantity price calculation? 回答1: Yes it's possible to disable the quantity item prices calculation, but it's quite complicated…

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

How can i get the updated cart session array and display it in another php file AJAX

删除回忆录丶 提交于 2020-04-28 21:18:24
问题 AJAX $(document).ready(function(){ //remove product from cart $(".delete-product-cart").click(function(e){ var id = $(this).data('id'); $.ajax({ url: "remove_from_cart.php", type: "GET", //send it through get method data: { id: id, }, success: function(response) { }, error: function(xhr) { //Do Something to handle error } }); }); }); //remove_from_cart.php <?php // start session session_start(); // get the product id $id = isset($_GET['id']) ? $_GET['id'] : ""; // remove the item from the

How can i get the updated cart session array and display it in another php file AJAX

江枫思渺然 提交于 2020-04-28 21:16:26
问题 AJAX $(document).ready(function(){ //remove product from cart $(".delete-product-cart").click(function(e){ var id = $(this).data('id'); $.ajax({ url: "remove_from_cart.php", type: "GET", //send it through get method data: { id: id, }, success: function(response) { }, error: function(xhr) { //Do Something to handle error } }); }); }); //remove_from_cart.php <?php // start session session_start(); // get the product id $id = isset($_GET['id']) ? $_GET['id'] : ""; // remove the item from the

Display a custom calculated cart item price in WooCommerce

前提是你 提交于 2020-03-24 00:37:10
问题 In WooCommerce, I'm trying to calculate the price of a variable product in the cart. I want to multiply the product price with some custom cart item numerical value. Here is my code: add_filter( 'woocommerce_cart_item_price', 'func_change_product_price_cart', 10, 3 ); function func_change_product_price_cart($price, $cart_item, $cart_item_key){ if (isset($cart_item['length'])){ $price = $cart_item['length']*(price of variation); return $price; } } The price calculation doesn't work. What I am

Change cart items subscription properties values before checkout

≡放荡痞女 提交于 2020-03-23 06:24:06
问题 This may be a noob question so apologies in advance. I have variable subscription products whose price varies by subscription length. I also have simple subscriptions that have a subscription_length = 0. When the cart contains both types, Woocommerce subscriptions creates two subscriptions. I am trying to modify the subscription_length metadata of all the items in the cart to match the longest length in the cart so only one subscription will be created. I just can't seem to find right way to

Append custom field value in WooCommerce product name on cart and checkout

|▌冷眼眸甩不掉的悲伤 提交于 2020-03-23 05:05:13
问题 I'm trying to change the name of the product in cart and checkout pages. I have the following code to add some cart meta data: function render_meta_on_cart_and_checkout( $cart_data, $cart_item = null ) { $custom_items = array(); /* Woo 2.4.2 updates */ if( !empty( $cart_data ) ) { $custom_items = $cart_data; } if( isset( $cart_item['sample_name'] ) ) { $custom_items[] = array( "name" => $cart_item['sample_name'], "value" => $cart_item['sample_value'] ); } return $custom_items; } add_filter(

Custom notice based on cart item stock quantity in Woocommerce

久未见 提交于 2020-02-29 07:21:11
问题 I am trying to create a function for wordpress/woocommerce to show an option in the cart page for split delivery. What it should do is to check the stock status of all items in cart. First case: If all items in cart are available output nothing. Second case: If all items in cart are out of stock, output nothing. Third case: The only condition when something should be shown is, when both cases (first and second) occurs. So only if the cart has items in stock AND has items out of stock it