Woocommerce Cart price not matching the selected product price - php

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

Related

I want to add a feature in woocommerce cart were user can add margin and it should with total price of a procuct in woocommerce

Expected Result
I want a feature where user can add margin in a product price for which he is placing order in woocommerce cart or checkout page.

Changing cart product price in Woocommerce

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.

Magento 2 wrong product price in cart after removal of category discount

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.

Magento get final price with Cart discount

I am working with cross-selling on my shopping cart page.
I have two products: #001 and #002.
Currently, if product #001 is in the cart, the upsell will display a message about #002.
I would like to get #002's finalPrice-(cart rules), so that the price is displayed with the discount, based on the fact that product #001 is in the cart.
How can I subtract the cart discount given on #002?
Currently, with getFinalPrice(), the full price "499,-" is displayed, even though #001 is added to the cart, and has rules that tells #002 to have 50% discount.

Prestashop block cart and cart controller

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

Categories