cart

Conditionally set cart item prices for specific products in WooCommerce 3

社会主义新天地 提交于 2019-12-02 11:54:47
In WooCommerce I am using some code from this answer: Set WooCommerce cart item price to zero if the product has already been bought It works great with one product, but I would like to make it work with several products . So the code below, for a specific product, change the cart item price to $0.00 if customer has already purchased and if not the price is set to $100 (for the first purchase) : add_action( 'woocommerce_before_calculate_totals', 'conditionally_change_cart_items_price', 10, 1 ); function conditionally_change_cart_items_price( $cart_object ) { if ( is_admin() && ! defined(

Magento cart / session data outside magento

人盡茶涼 提交于 2019-12-02 11:41:44
问题 This might get a little confusing as I have tried everything to make this work. All I want is a link in my brand site (domain.com) which shows the qty in my magento 1.5.1 cart (domain.com/shop) I quite easily pulled in product data and navigation blocks but no matter what I do, cart qty is always 0 from outside magento. The main way I tried was just in my brand site to go: require_once $_SERVER['DOCUMENT_ROOT'].'/shop/app/Mage.php'; umask(0); Mage::app(); Mage::getSingleton('core/session',

Minimum cart item quantity for a specific product category in WooCommerce

浪子不回头ぞ 提交于 2019-12-02 10:51:13
问题 In WooCommerce, I need to set up a minimum quantity for each item of a product category. I searched the forum and found some code that works fine except it only counts the Quantity for a product category in total: add_action( 'woocommerce_checkout_process', 'wc_minimum_order_amount' ); add_action( 'woocommerce_before_cart' , 'wc_minimum_order_amount' ); function wc_minimum_order_amount() { $minimum = 5; //Qty product if ( WC()->cart->cart_contents_count < $minimum ) { $draught_links = array()

Only one currently added product into Woocommerce cart?

☆樱花仙子☆ 提交于 2019-12-02 10:14:26
问题 I would like Woocommerce to only allow 1 product in the cart. If a product is already in the cart and another one is added then it should remove the previous one. I found this code on net: /** * When an item is added to the cart, remove other products */ function custom_maybe_empty_cart( $valid, $product_id, $quantity ) { if( ! empty ( WC()->cart->get_cart() ) && $valid ){ WC()->cart->empty_cart(); wc_add_notice( 'Only allowed 1 item in cart, please remove previous item.', 'error' ); // here

Adding Woocommerce Brands names to cart item product names

人盡茶涼 提交于 2019-12-02 09:27:16
I use the Woocommerce Brands plugin and I would like to add the Brand to each product when it is in the cart, like it displays variations. So Product Name, and then Size: XXX Colour: XXX Brand: XXX I have tried a few ways of doing it but I can't seem to get it to work. Update 2 - Code enhanced and optimized (April 2019) Now the way to add brand name(s) just as the product attributes names + values in cart items, is also possible using this custom function hooked in woocommerce_get_item_data filter hook. The code will be a little different (but the same to get the brand data): add_filter(

Retrieve data from cart and send using mail

你说的曾经没有我的故事 提交于 2019-12-02 09:25:07
This project is with E-Commerce. There is option to Add to Cart . When user click on add, product will be added to his cart as well and working fine. But finally when user click place order button Admin will receive Mail with products. That E-mail body should content should display like below. I tried with using foreach and echo data row by row. But its useless . Question is - I want retrieve data from cart and add to Above table Format and then it will end with mailing. How to archive this with CI? Html Table Format $to = 'mail@gmail.com'; $msg .= ' <table id="table" border="0" cellpadding=

Apply a discount for a specific user role in Woocommerce

不想你离开。 提交于 2019-12-02 09:04:57
问题 I have a woocommerce store, with 3 user roles, I want to provide a 10% discount on the cart total only for a user role 'company'. I found "Percentage discount based on user role and payment method in Woocommerce" answer that is very neer of what I need, but don't know how to modify the code to feet my needs, as it contains also a condition based on payment method and displaying the discount only at checkout, but I need it to display in cart as well. 回答1: The following code will apply a 10%

Add different custom labels to Woocommerce shipping methods

只愿长相守 提交于 2019-12-02 06:45:45
In WooCommerce, I am trying to add "shipping estimates" to my shipping methods (all of them are flat rate type), so it looks like this: Only all the estimated dates are different… My problem is that I can't seem to target specific instances. I can only select entire method (flat rate), I checked for my methods instance ID's, since those are unique: But it only works when I put 0 as a case in php switch method. 2,3,4,5,7 do not work. Here is my code: function sv_shipping_method_estimate_label($label, $method) { $label. = '<br /><small>'; switch ($method - > instance_id) { case 0: $label. = 'Est

Hide specifics Flat Rates when Free Shipping is available in WooCommerce 3

Deadly 提交于 2019-12-02 04:35:26
问题 In WooCommerce 3, I have these shipping options (settings): Free Shipping: free_shipping:1 - Minimum order amount is set at $50 . Normal Shipping flat_rate:3 - Amount $5 . Express Shipping flat_rate:5 - Amount $10 . I would like Express Shipping option to be always available (shown). But when Free shipping is available (meaning that the customer has more than $50 in the cart) I would like to hide Normal Shipping only. So when Free shipping is NOT available (and hidden), the available shipping

Magento cart / session data outside magento

心不动则不痛 提交于 2019-12-02 04:32:23
This might get a little confusing as I have tried everything to make this work. All I want is a link in my brand site (domain.com) which shows the qty in my magento 1.5.1 cart (domain.com/shop) I quite easily pulled in product data and navigation blocks but no matter what I do, cart qty is always 0 from outside magento. The main way I tried was just in my brand site to go: require_once $_SERVER['DOCUMENT_ROOT'].'/shop/app/Mage.php'; umask(0); Mage::app(); Mage::getSingleton('core/session', array('name'=>'frontend')); // trying everything Mage::getSingleton('checkout/cart')->getItemsCount(); //