I'm using the following answer code that enable product quantity fields in shop and archive pages:
Show quantity box with add to cart ajax enabled in Woocommerce shop page and its work great.
This code work fine the problem is: when i am on a single product page and product has a minimum amount to order (5 for example) the code put the same minimum amount at the releated products (even if they dont have a minimum amount for order)
Related
I have a woocommerce shop with 3 products (rolling lawns). These products have many different pricing configurations based on geolocation (for delivery) of the customer and quantity(meters) selected. So for all the different quantity levels (below 60 meters, below 100 meters,...) and the zip code I have a product variation for this product with its own price. Now a requirement is that on a specific page I have to show, based on the input of zip code and quantity, a product which the user can add to cart. The price has to adapt to the input of course, thats why I want to use the variation which has the price per meter and multiply it with the quantity. I cannot figure out how to display the needed variation as a product where the customer can click "add to cart". Is this possible? Or have I failed the topic and should solve this a total other way and not with variations?
I wanted to implement a buy 3 free 1 feature, so I wrote a script that detect whether customer has 3 same items in cart and automatically add 1 more same item to the cart. Then using another hook, I overwrite the price of the product to 0.
I googled the solution and used the same approach found on:
WooCommerce: Add product to cart with price override?
woocommerce add custom price while add to cart
Here is the code sample:
function setGiftPriceToZero($cart_object){
foreach($cart_object->cart_contents as $k=>$item):
if(isset($item['variation']['promo']) && ($item['variation']['promo']) == 'buy 3 free 1'):
$item['data']->price = 0;
endif;
endforeach;
}
add_action('woocommerce_before_calculate_totals', 'setGiftPriceToZero');
When Woocommerce calculate the subtotal for the cart, it always add in the original price of the product that is supposed to be free. For example, when I added 3 $100 item to cart, the cart subtotal ends up with $400 instead of $300.
I digged deeper into the Woocommerce code and found that in https://docs.woocommerce.com/wc-apidocs/source-class-WC_Cart.html#1139, $item['data']->get_price() is used which always return the original price for the item.
Is there anyway to fix this using hooks/apis instead of editing Woocommerce core file?
I have found the culprit of this error. It's caused by conflict from another plugin called Woocommerce Role Based Price. This plugin overwrite the cart item price at the end of the cart total calculation flow. This is why get_price() function always return the specified price for the item.
Now I only have to edit the plugin file so that it plays nicely with my logic.
If I have many products on one category and I want to give discounts for specific quantity like: 2 for 10% off, 3 for 15% off and 4 for 20% off in any product they purchased on that same category.
I've tried to find extensions in opencart but I didn't found one. Does anyone knows any extension for this in opencart?
Thank you.
This features is already exits int the open cart system.
Go to that product form in the admin panel,
Home -> Product-> In product form there is a Discount tab,you can set price for every product according to the quantity.
I'm having problems trying to show the product full total price in Magento, and by product total price I mean full product price without the discount; the price has to be multiplied for each product quantity added to the cart, and custom options additional price should be added as well. Which files should I edit in Magento? is it possible to show the product discount inside the cart (amount that varies with the amount of ordered products)?
Thanks
Edit:
screenshot
In the blue rectangle it shows the regular price, which should be regular price X 2 (since product quantity is 2) with added 122€ as chosen in product special options. Instead now it shows regular price with discount applied and for only 1 product, without special option added.
Please suppose:
Row product price = $1.5;
Quantity = 3;
Instead of total amount $4.5, it should be different amount based on finished product criteria.
Using configurable product options/attributes, my product page can display its finished product price correctly based on a special formula (written in JS).
Though I can calculate correctly using JS function (formula) on product page, I can't display its calculated amount on shopping cart page. How can I pass the calculated amount to shopping cart page so that its calculation persists in rest of steps in checkout?
You need an observer when adding products to cart, based on the same logic (options and quantity) as your JS function.
You have to build an observer that catches the add-to-cart event sales_quote_add_item and put your logic there. You can define the product price with
$observer->getEvent()->getQuoteItem()->setOriginalCustomPrice([your price])
This price will be saved to the quote object and persists in other steps in checkout.
If you want to calc the row total separate from price per item, you have to overwrite the calcRowTotal() method from the Mage_Sales_Model_Quote_Item class like explained here:
http://www.magentocommerce.com/boards/viewthread/220715/