Open virsoni opened 8 years ago
Can anyone reply on my issue please?
Can anyone reply on this issue please?
Can anyone reply on this issue please?
Your problem is the order of counting the VAT and the discount. The way Total gets counted:
If VAT applies to the subtotal after substracting discount, then 209 is fine. If you want 210 for total, you have to apply VAT to the subtotal, and then discount on subtotal, and then add them, but i don't think this is the correct way.
thank you for reply. If i go with your suggestion as under.
How can I get 190 as subtotal with discount to apply VAT?
I'm not sure, but try changing the order off applying conditions:
If it's not working that means VAT is applied to the total after applying other conditions. If that doesn't work, try the following workarounds: a) for the discount use item conditions (for every item) (see docs for per-item conditions) b) try to add VAT as normal condition (don't use type = tax). you will still be able to get the amount of vat applied.
Okay. we can get normal sub total using this function: Cart::getSubTotal().
My query is: How can i get the sub total with applied condition using one call is there any function?
/**
NOTE: All cart based conditions should be applied before calling Cart::getTotal() Then Finally you can call Cart::getTotal() to get the Cart Total with the applied conditions.
$cartTotal = Cart::getTotal(); // the total will be calculated based on the conditions you ave provided
Next is the Condition on Per-Item Bases.
is this what you are looking for?
yes that is correct but assume when we applied both conditions and again go to any product page than come again to cart page order calculation not working properly as getTotal() function take the final total.
I have to follow this way to display order summary.
<tr>
<td>Order subtotal</td>
<th align="right">${{number_format(Cart::getSubTotal(),2)}}</th>
</tr>
{{--*/ $condition = Cart::getCondition('VAT') /*--}}
{{--*/ $vat = 0 /*--}}
@if($condition)
<tr>
<td>{{$condition->getName()}} ({{$condition->getValue()}})</td>
<th align="right">${{number_format($condition->getCalculatedValue(Cart::getSubTotal()),2)}}</th>
</tr>
{{--*/ $vat = $condition->getCalculatedValue(Cart::getSubTotal()) /*--}}
@endif
{{--*/ $condition = Cart::getCondition('Discount') /*--}}
@if($condition)
<tr>
<td>{{$condition->getName()}} ({{$condition->getValue()}})</td>
<th align="right">${{number_format($condition->getCalculatedValue(Cart::getSubTotal()+$vat),2)}} </th>
</tr>
@endif
<tr class="total">
<td>Total</td>
<th align="right">${{number_format(Cart::getTotal(),2)}}</th>
</tr>
I can not pass Cart::getTotal() function as parameter of $condition->getCalculatedValue() for discount condition.... otherwise it will calculate discount on final total.
please let me know your thoughts if you get my problem.
@virsoni You can add an order of appliance for the conditions. So you can add them in every part of the code and the getConditions will apply in the order you have specified.
Hi I have configure cart and applied few condition for testing purpose but cart total or discount total is not display correctly can you please help me below is my code?
$condition1 = new \Darryldecode\Cart\CartCondition(array( 'name' => 'VAT', 'type' => 'tax', 'target' => 'subtotal', 'value' => '10%', ));
$itemCondition3 = new \Darryldecode\Cart\CartCondition(array( 'name' => 'Discount', 'type' => 'misc', 'target' => 'subtotal', 'value' => '-5%', ));
Cart::condition([$condition1,$itemCondition3]);