- Posts: 50
- Thank you received: 1
Call variant price on main product page
- hawkeyentjc
-
Topic Author
- Offline
Less
More
14 years 4 months ago #50355
by hawkeyentjc
Call variant price on main product page was created by hawkeyentjc
Hi,
Is there any way I can place the variant pricing anywhere in the main product page? What code do I have to use?
I'm doing a book retail so we have characteristics like:
Format available: Paperback, eBook.
For example, let's say-
Main Product: Book A
Variant #1: Book A [Paperback] $15
Variant #2: Book A [eBook] $5
So what we want to do is to place the pricing somewhere in the product/show layout:
Paperback $15
eBook $5
What code do I have to use to put those two variant prices into the main product page?
Thanks.
Is there any way I can place the variant pricing anywhere in the main product page? What code do I have to use?
I'm doing a book retail so we have characteristics like:
Format available: Paperback, eBook.
For example, let's say-
Main Product: Book A
Variant #1: Book A [Paperback] $15
Variant #2: Book A [eBook] $5
So what we want to do is to place the pricing somewhere in the product/show layout:
Paperback $15
eBook $5
What code do I have to use to put those two variant prices into the main product page?
Thanks.
Please Log in or Create an account to join the conversation.
14 years 4 months ago #50393
by Xavier
Replied by Xavier on topic Re: Call variant price on main product page
Hi hawkeyentjc,
You can use this code to display the pricing of each variants in your main product page:
You can use this code to display the pricing of each variants in your main product page:
Code:
echo "<table>";
foreach($this->element->variants as $variant){
echo "<tr>";
if($variant->prices[0]->price_value != null){
echo "<td>".$variant->product_code."</td>";
echo "<td>".$variant->prices[0]->price_value."</td>";
}
echo "</tr>";
}
echo "</table>";
Please Log in or Create an account to join the conversation.
- hawkeyentjc
-
Topic Author
- Offline
Less
More
- Posts: 50
- Thank you received: 1
14 years 4 months ago #50608
by hawkeyentjc
Replied by hawkeyentjc on topic Re: Call variant price on main product page
Hi Xavier,
The coding works great.
As of now, it doesn't display the currency symbol and the decimal point can go up to 5 points. Example:
Paperback 15.00000
eBook 5.00000
Is there any way to tweak the code so that it can display with currency symbol and also 2 decimal point only?
Paperback $ 15.00
eBook $ 5.00
Thanks!
The coding works great.
As of now, it doesn't display the currency symbol and the decimal point can go up to 5 points. Example:
Paperback 15.00000
eBook 5.00000
Is there any way to tweak the code so that it can display with currency symbol and also 2 decimal point only?
Paperback $ 15.00
eBook $ 5.00
Thanks!
Please Log in or Create an account to join the conversation.
- hawkeyentjc
-
Topic Author
- Offline
Less
More
- Posts: 50
- Thank you received: 1
14 years 4 months ago #50616
by hawkeyentjc
Replied by hawkeyentjc on topic Re: Call variant price on main product page
Hi,
This is another side question.
The code given above I believe only works for Product/Show page.
Is there any code to call the variant price into the Product --> listing_table view?
Many thanks!
This is another side question.
The code given above I believe only works for Product/Show page.
Is there any code to call the variant price into the Product --> listing_table view?
Many thanks!
Please Log in or Create an account to join the conversation.
14 years 4 months ago #50687
by nicolas
Replied by nicolas on topic Re: Call variant price on main product page
You can use that code:
echo $this->currencyHelper->format($variant->prices[0]->price_value,$variant->prices[0]->price_currency_id)
instead of:
$variant->prices[0]->price_value
for that.
Regarding the products listing, that won't be possible as the data is not loaded on the products listings for variants (that would be too resource intensive on big websites and it's not necessary in the default views we have).
echo $this->currencyHelper->format($variant->prices[0]->price_value,$variant->prices[0]->price_currency_id)
instead of:
$variant->prices[0]->price_value
for that.
Regarding the products listing, that won't be possible as the data is not loaded on the products listings for variants (that would be too resource intensive on big websites and it's not necessary in the default views we have).
Please Log in or Create an account to join the conversation.
- hawkeyentjc
-
Topic Author
- Offline
Less
More
- Posts: 50
- Thank you received: 1
14 years 4 months ago #50746
by hawkeyentjc
Replied by hawkeyentjc on topic Re: Call variant price on main product page
Cool. It works great!
Thanks!
Thanks!
Please Log in or Create an account to join the conversation.
Time to create page: 0.175 seconds