cart

WooCommerce - Adding a custom price to each product in cart

夙愿已清 提交于 2019-12-18 09:05:15
问题 I would like to update the price of products adding a custom price in cart using this simple piece of code update_post_meta( $product->id, '_regular_price', $frame_price_added); . Note: what I'm trying to achieve is to add this custom price to each product in cart. I have try to get $frame_price_added this way: $frame_price = $res['_number_field'][0]; $frame_price_added = $product->price + $frame_price; Here $product->price is price coming from woocomerce product and $frame_price is coming

Change cart and checkout button links on WooCommerce mini cart widget

旧巷老猫 提交于 2019-12-18 08:54:36
问题 On Woocommerce, how can we change the URLs on "View cart" and "Checkout" links on the drop down menu that show up on hover over the shopping cart icon on the the home page? I have the "cart" and "checkout" pages setup but they are not linked to these. I can view these pages directly with urls. http://mysite/cart and http://mysite/checkout 回答1: It seems that there is a problem somewhere with your theme (or in a plugin), as the minicart button links always point to the right cart and checkout

WooCommerce - Skip cart page redirecting to checkout page

浪尽此生 提交于 2019-12-18 07:07:10
问题 Our website is kohsamuitour.net. I have added custom code to skip the cart page on checkout, which works for all sales. This code: function wc_empty_cart_redirect_url() { return 'https://www.kohsamuitour.net/all-tours/'; } add_filter( 'woocommerce_return_to_shop_redirect', 'wc_empty_cart_redirect_url' ); Now that does the job, but we also have a possibility to check booking availability. That can be found on the pages of private charters, i.e. this one: https://www.kohsamuitour.net/tours/kia

Progressive discount based on cart total in WooCommerce

点点圈 提交于 2019-12-18 04:27:08
问题 I'm trying to automatically apply 3 different coupon codes in WooCommerce Cart. Here's my code! add_action( 'woocommerce_before_cart', 'apply_matched_coupons' ); function apply_matched_coupons() { global $woocommerce; $coupon_code5 = '5percent'; $coupon_code10 = '10percent'; $coupon_code55 = '15percent'; if ( $woocommerce->cart->has_discount( $coupon_code ) ) return; if ( $woocommerce->cart->cart_contents_total >= 50 && $woocommerce->cart->cart_contents_total < 100 && $woocommerce->cart->cart

Woocommerce: custom jquery event after added to cart

会有一股神秘感。 提交于 2019-12-17 19:47:16
问题 Im trying (in archive) handle event after some product was added to cart (1 action on picture), I want catch that moment and update "Total number of products" (3 action on picture) of my mini cart in navigation menu. (With action 2 is all ok) Not working by me second code: $( document.body ).on( 'added_to_cart', function(){ console.log('added_to_cart'); }); My custom code inited after when woocommerce js files are loaded. If I will edit add-to-cart.min.js core file and insert my own logic,

WooCommerce Cart - Conditional Items categories validation

非 Y 不嫁゛ 提交于 2019-12-17 17:15:21
问题 We have an exclusive category X and others regular categories Y . What I would like: When someone orders anything from category X , other category items cannot be added to cart and should display a warning category Y products should not be mixed with X . How could I achieve that? I got this code from other post, but its outdated and not satisfactory: <?php // Enforce single parent category items in cart at a time based on first item in cart function get_product_top_level_category ( $product

Set cart item price from a hidden input field custom price in Woocommerce 3

為{幸葍}努か 提交于 2019-12-17 16:55:09
问题 In Woocommerce, I used jQuery to calculate a custom price on a single product pages, and now need to pass this value to the cart. The desired behavior is to pass the new price retrieved from the hidden field to the cart item price. Here is my actual code: // Hidden input field in single product page add_action( 'woocommerce_before_add_to_cart_button', 'custom_hidden_product_field', 11, 0 ); function custom_hidden_product_field() { echo '<input type="hidden" id="hidden_field" name="custom

Changing the Add To Cart button text in WooCommerce for items with variations

戏子无情 提交于 2019-12-17 14:58:13
问题 I'm running WooCommerce version 2.5.5. The following lines of code don't seem to change the Add To Cart button text on my product page for an item with variations: add_filter('variable_add_to_cart_text', 'my_custom_cart_button_text'); function my_custom_cart_button_text() { return __('Buy Now', 'woocommerce'); } Would you happen to know what I'm missing? 回答1: The correct filter for the single product page is woocommerce_product_single_add_to_cart_text. function my_custom_cart_button_text(

Remove Canada from country list when specific products are in cart on Woocommerce

ⅰ亾dé卋堺 提交于 2019-12-13 17:52:32
问题 I want to do something simple: do not ship a particular product to Canada. Here's the easiest way to do it in my opinion: if that particular product is present in the cart, remove Canada from checkout page. Particular products: 1- https://constructioncovers.com/product/insulated-cement-curing-blankets/ (ID: 12616) 2- https://constructioncovers.com/product/insulated-construction-tarps/ (ID: 15631) My research: This article gave me a way to find products in cart and perform any action if

WooCommerce Avoid add to cart for non logged user

杀马特。学长 韩版系。学妹 提交于 2019-12-13 17:34:23
问题 In my WooCommerce shop, when a customers is not logged in I would like to avoid him adding to cart asking him to either login or register an account… Is it possible? 回答1: Updated - You could use this 2 little snippets of code, that will: Replace add-to-cart button/link in shop pages and archives pages (for non logged in users). Avoid non logged in customers adding to cart and displaying a custom message. Here is the code: // Replacing add-to-cart button in shop pages and archives pages (forn