cart

Add custom fields to custom product calculated price in Woocommerce

ぃ、小莉子 提交于 2019-12-11 00:47:47
问题 In Woocommerce, I added some custom fields to my product single pages, based on this answer code: Add a custom product calculated price to Woocommerce cart. This is my code: // Add a custom field before single add to cart add_action( 'woocommerce_before_add_to_cart_button', 'custom_product_price_field', 5 ); function custom_product_price_field(){ echo '<div class="custom-text text"> <h3>Rental</h3> <label>Start Date:</label> <input type="date" name="rental_date" value="" class="rental_date" /

Custom cart count is not updating without reloading in Woocommerce

∥☆過路亽.° 提交于 2019-12-11 00:36:00
问题 I have the ajax script enqueued, but I can't seem to get the cart items count updated without refreshing the page. Functions: // Add scripts and stylesheets function startwordpress_scripts() { wp_enqueue_style( 'reset', get_template_directory_uri() . '/reset.css' ); wp_enqueue_style( 'style', get_template_directory_uri() . '/style.css' ); wp_enqueue_style( 'style', get_template_directory_uri() . '/veggiee.css'); wp_enqueue_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/3.1.1

Re-calculate totals after setting cart item prices in Woocommerce

佐手、 提交于 2019-12-11 00:32:13
问题 How i can change subtotal price after i changed the price of product by the set_price() method? Now it is calculate the total cost at old prices in review-order.php. cart.php foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { ... $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key ); $product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key ); ... $_product->set

WooCommerce discount: buy one get one 50% off

半腔热情 提交于 2019-12-10 23:55:45
问题 I wish to set up a specific discount on a particular variable products, if customer buys one product they get the another(same) on 50% discount(Buy one get another for 50% off). I've tried many discount plugins buy the closest that I have found are: Pricing Deals for WooCommerce WooCommerce All Discounts Lite WooCommerce Extended Coupon Features By using these plugins I was able to setup discount on subtotal or discount on a each product but not exactly what I am looking for(Buy 1 get 1 off).

Remove Woocommerce cart quantity selector from cart page

拜拜、爱过 提交于 2019-12-10 23:54:59
问题 I am trying to remove Woocommerce cart quantity selector from the cart page. I am using the quantity input field on my shop archive pages and it has applied it to the cart page. How can I remove it and not allow the user to change it? I have tried the following with the code below, researched and found from official Woocommerce docs but it is doesnt apply the rule... function wc_remove_quantity_field_from_cart() { if ( is_cart() ) return true; } add_filter( 'woocommerce_is_sold_individually',

Progressive percent discount based on cart amount

﹥>﹥吖頭↗ 提交于 2019-12-10 23:14:47
问题 I am trying to make a simple discount code for WooCommerce that gives you a percent discount before buying. Lets say that if you add products worth $100 you get 2% discount and if you add products worth $250 you get 4%, etc. The only thing I found was this: // Hook before calculate fees add_action('woocommerce_cart_calculate_fees' , 'add_custom_fees'); /** * Add custom fee if more than three article * @param WC_Cart $cart */ function add_custom_fees( WC_Cart $cart ){ if( $cart->cart_contents

How to skip cart page on woocomerce for certain products only?

自古美人都是妖i 提交于 2019-12-10 22:45:47
问题 I added this to my functions.php file : add_filter ('woocommerce_add_to_cart_redirect', 'woo_redirect_to_checkout'); function woo_redirect_to_checkout() { $checkout_url = WC()->cart->get_checkout_url(); return $checkout_url; } But now, all the products are re-directing strait to check-out. I would like to have this option only in one product. Is that a way I can add a product ID to that same filer? Thank you! 回答1: You need to get the product when It is just added to cart , then check if for

Add multiple products to cart if they are not already in cart

徘徊边缘 提交于 2019-12-10 18:55:57
问题 In WooCommerce I've implemented @jtsternberg's WooCommerce: Allow adding multiple products to the cart via the add-to-cart query string to allow adding multiple products at once, but I've received many complaints from customers who actually try to use one of the links containing multiple products. For starters, if the customer clicks checkout and then clicks the browser "back" button, all the item quantities increment. I solved this by redirecting the user to the cart URL stripped of any

Max item quantity added to cart based on product category in Woocommerce

久未见 提交于 2019-12-10 18:25:46
问题 I am trying to customize the shop such that Category named Quantity4 allows only 4 items to be added in the cart and category named Quantity6 allows only items to be added in the cart. As far as I can get, this can be achieved using nested if statements, but somehow this doesn't work. add_filter( 'woocommerce_add_to_cart_validation', 'only_four_items_allowed_add_to_cart', 10, 3 ); function only_four_items_allowed_add_to_cart( $passed, $product_id, $quantity ) { $cart_items_count = WC()->cart-

Shopping cart items not showing in customer view

◇◆丶佛笑我妖孽 提交于 2019-12-10 14:59:05
问题 Running Magento 1.7.2. When inside the customer view in the administrator it shows 1 item in the customers cart but not the details. I’ve attached a screen shot. Does anyone know what the issue could be or can you verify that it’s working properly so I know it’s my installation? Thanks. View Screenshot Here 回答1: [Solved] on app\code\core\Mage\Adminhtml\controllers\CustomerController.php 1.7.0 public function viewCartAction() { $this->_initCustomer(); $layout = $this->loadLayout() ->getLayout(