- Posts: 26
- Thank you received: 1
show price without discount
- fernandoIncerco
-
Topic Author
- Offline
Less
More
7 years 3 months ago #308223
by fernandoIncerco
show price without discount was created by fernandoIncerco
-- HikaShop version -- : 4.1
-- Joomla version -- : 3.9
Hello,
I am trying to display the price without discount in the checkout, for this I he¡avre edited
checkout / show_block_cart.php view and added a new line like this:
<td class="hikashop_cart_subtotal_value" data-title="<?php echo JText::_('SUBTOTAL'); ?>">
<span class="hikashop_checkout_cart_subtotal"><?php
echo $this->currencyClass->format(@$cart->total->prices[0]->price_value_without_discount,@$cart->total->prices[0]->price_currency_id);
?></span>
</td>
The problem is that always get 0€ in this field
-- Joomla version -- : 3.9
Hello,
I am trying to display the price without discount in the checkout, for this I he¡avre edited
checkout / show_block_cart.php view and added a new line like this:
<td class="hikashop_cart_subtotal_value" data-title="<?php echo JText::_('SUBTOTAL'); ?>">
<span class="hikashop_checkout_cart_subtotal"><?php
echo $this->currencyClass->format(@$cart->total->prices[0]->price_value_without_discount,@$cart->total->prices[0]->price_currency_id);
?></span>
</td>
The problem is that always get 0€ in this field
Please Log in or Create an account to join the conversation.
7 years 3 months ago #308225
by nicolas
Replied by nicolas on topic show price without discount
Hi,
The price_value_without_discount on the total of the cart is the price without coupon applied. And if you don't have any coupon applied it is not set.
The total of the cart without discounts is not calculated anywhere, so you would have to calculate it in your custom code I'm afraid by looping on the $cart->products array.
The price_value_without_discount on the total of the cart is the price without coupon applied. And if you don't have any coupon applied it is not set.
The total of the cart without discounts is not calculated anywhere, so you would have to calculate it in your custom code I'm afraid by looping on the $cart->products array.
Please Log in or Create an account to join the conversation.
- fernandoIncerco
-
Topic Author
- Offline
Less
More
- Posts: 26
- Thank you received: 1
7 years 3 months ago #308246
by fernandoIncerco
Replied by fernandoIncerco on topic show price without discount
Thanks Nicolas I will try...
Please Log in or Create an account to join the conversation.
- fernandoIncerco
-
Topic Author
- Offline
Less
More
- Posts: 26
- Thank you received: 1
7 years 3 months ago - 7 years 3 months ago #308279
by fernandoIncerco
Replied by fernandoIncerco on topic show price without discount
Finally I think I get it:
$price_without_discount = 0;
foreach($cart->products as $i => $product) {
if(empty($product->cart_product_quantity))
continue;
if($group && !empty($product->cart_product_option_parent_id))
continue;
$price_without_discount += $product->prices[0]->price_value_without_discount;
}
$price_without_discount = 0;
foreach($cart->products as $i => $product) {
if(empty($product->cart_product_quantity))
continue;
if($group && !empty($product->cart_product_option_parent_id))
continue;
$price_without_discount += $product->prices[0]->price_value_without_discount;
}
Last edit: 7 years 3 months ago by fernandoIncerco.
The following user(s) said Thank You: nicolas
Please Log in or Create an account to join the conversation.
- fernandoIncerco
-
Topic Author
- Offline
Less
More
- Posts: 26
- Thank you received: 1
7 years 4 weeks ago #310583
by fernandoIncerco
Replied by fernandoIncerco on topic show price without discount
Hi to all,
I want to do the same (display the price without discount) in the show_default.php , but here the cart objet is still empty...
How can I show it in this view?
Thanks
I want to do the same (display the price without discount) in the show_default.php , but here the cart objet is still empty...
How can I show it in this view?
Thanks
Please Log in or Create an account to join the conversation.
7 years 4 weeks ago #310585
by nicolas
Replied by nicolas on topic show price without discount
Hi,
The price without discount is already available in a variable on the product page.
You can just display it:
The price without discount is already available in a variable on the product page.
You can just display it:
Code:
echo $this->element->prices[[0]->price_value_without_discount;
Please Log in or Create an account to join the conversation.
- fernandoIncerco
-
Topic Author
- Offline
Less
More
- Posts: 26
- Thank you received: 1
7 years 4 weeks ago #310618
by fernandoIncerco
Replied by fernandoIncerco on topic show price without discount
Hi Nicolas,
With this I see the price of the product without options, to add the option price I tried:
but is not working
With this I see the price of the product without options, to add the option price I tried:
Code:
$price_without_dto= $this->element->prices[0]->price_value_without_discount;
foreach($this->element->options as $optionElement){
$price_without_dto+= $optionElement->order_product_price;
}
but is not working
Please Log in or Create an account to join the conversation.
7 years 4 weeks ago #310620
by nicolas
Replied by nicolas on topic show price without discount
Hi,
The price with options is calculated dynamically with javascript at the bottom of the "option.php" file of the "product" view.
Also, your code is not correct.
Supposing that your option doesn't have variants, then you can use such code instead:
If it has, then it should be something like that (however, this will add the price of all the variants of the option to the main product price so you'll likely want to adapt it based on what you want):
The price with options is calculated dynamically with javascript at the bottom of the "option.php" file of the "product" view.
Also, your code is not correct.
Supposing that your option doesn't have variants, then you can use such code instead:
Code:
$price_without_dto= $this->element->prices[0]->price_value_without_discount;
foreach($this->element->options as $optionElement){
$price_without_dto+= $optionElement->prices[0]->price_value;
}
Code:
$price_without_dto= $this->element->prices[0]->price_value_without_discount:
foreach($this->element->options as $optionElement){
foreach($optionElement->variants as $variant) {
$price_without_dto+= $variant->prices[0]->price_value;
}
}
The following user(s) said Thank You: fernandoIncerco
Please Log in or Create an account to join the conversation.
- fernandoIncerco
-
Topic Author
- Offline
Less
More
- Posts: 26
- Thank you received: 1
7 years 3 weeks ago #310670
by fernandoIncerco
Replied by fernandoIncerco on topic show price without discount
Ok I forgot that the calculation was in the option.php.
Done and working!!! Thanks so much
Done and working!!! Thanks so much
Please Log in or Create an account to join the conversation.
Time to create page: 0.215 seconds