We have followed this guys tutorial on changing the prestashop add to cart animation
http://nemops.com/better-prestashop-add-to-cart/
However, now the problem we face is if someone adds a quantity to the cart that is greater than the quantity we have in stock. The popup box still shows and we still get the default prestashop error "There isn't enough product in stock".
We thought that in the ajax-cart.js where we added the new code that we could run and if statement against the quantity added and the quantity in stock. If the quantity added is greater than what we have in stock then do not display the box. We are stuck on how to check the quantity added vs the quantity in stock.
Get the quantity you have
var availableQuantity = {$product->quantity};
and then dissable add to cart button if available quantity is less then added to cart value
Related
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)
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.
In Magento 2 I have created a custom module category discount. When active its working fine for product list, details and cart view page.
But when I remove this discount it shows the original price for list and details page which is correct but mini cart view shows me the discounted price which shouldn't be the case. However if I update the quantity then it's fine.
I don't want to click the update button in the mini cart view for the original price. I want to do this using an observer.
I have few variation products on my site. As you can see in the image, the price of the product added to cart it 199 Rupees. But when added, the price shown in the cart above is 179! I checked in the admin panel, edited the product but everything is fine. What could be the issue? I have also tried updating wordpress and woocommerce.
I am using <?php echo WC()->cart->get_cart_subtotal(); ?> inside header.php to get the total price but it returns (TotalPrice - DiscountedPrice) when coupon is applied. I want to show only total price and exclude discounted price.
SO the problem is, if the coupon is applied, which is saved, the price shown in cart is the discounted price. But when you go to cart page, it adds the tax rate and applies coupon again!. How to fix this issue!
It might be as simple as clearing the cache..
Woocommerce>>System Status >> Tools >> WC Transients >> Clear Transients
I am trying to add special price for my product in OpenCart 2.0.1.1 with custom theme. on first time it will show fine. but, When I click on add to cart button and trying to buy that product in checkout page special price is getting disappeared and it shows product MRP price, when I return to same product page special price is not shown, it only shows my MRP price.
You should assign a correct "Customer Group" when setting a special price for an item, if you delete this customer group later this special price will disappear.