News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

How to add "From" price?

Started by brooklynbase, February 22, 2016, 17:56:46 PM

Previous topic - Next topic

brooklynbase

Hello all,

I have a parent product and multiple child products. Some child products have higher prices than the other child products. In the product list view, I have the parent shown only, so users will have to click on the parent and then select child products via custom fields.

In the product list, the parent product (not orderable) currently shows the lowest price of its children which is correct. I want to let my customers know that this price is the lowest price of the children by adding a "From:" tag before this final price, e.g. "From: $300".

If I set a language override to change the "Sales price" to "From:" it would affect even the solo products with no children. Is there a way I can add the "From" to only products that have children?


Ghost

You'd have to create a custom prices.php sublayout and modify it. How to use sublayouts http://docs.virtuemart.net/tutorials/templating-layouts/199-sublayouts.html

The logic would be to check whether the product has children and add "From" if it does.

lindapowers

What we do is we do not set price in the parent product and the childs show the price of each child in the dropdown.

But I understand your request, would be cool to have a "from" or the parent to show the lowest price from the childs.

Studio 42

Hi,
I have do it simpler,on checking the array product->customfields["addtocart"] position, you can know, if you have cart options and change the label

lindapowers

Quote from: brooklynbase on February 22, 2016, 17:56:46 PM

In the product list, the parent product (not orderable) currently shows the lowest price of its children which is correct. I want to let my customers know that this price is the lowest price of the children by adding a "From:" tag before this final price, e.g. "From: $300".



Hello I forgot to ask you how you make this? I mean you manually write the lowest price in the parent or you have it automatically to show the lowest price of the childs cause that would be great.

Jörgen

Quote from: Studio 42 on March 15, 2016, 09:43:28 AM
Hi,
I have do it simpler,on checking the array product->customfields["addtocart"] position, you can know, if you have cart options and change the label

Sounds interesting, I have not done this in VM3 yet. So far I only check if the product has children and this I use for not showing the stock, because the stock for the parent does not give any real info. If it is a Child I show the correct child stock instead of the parents stock which seems to be the default. Deciding if the product is a parent can of course also be used to display the label From. I will have a go at this. Would be nice to have a good method for these repeating tasks.

If You have a better idea please share.

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Studio 42

Hi Jorgen,
I can perhaps add it to my generic child variant plugin, all child are loaded in the same loop, so it's possible to compare the price and modify the main product price and set a value in parent product eg. childPrice.
But in all case you have at end to overide the price display and add label by condition and don't use core jText display in this case.
The code should be something so
replace
echo $currency->createPriceDiv ('salesPrice', 'COM_VIRTUEMART_PRODUCT_SALESPRICE', $product->prices);
with

if (isset($product->childPrice)) $label = 'COM_VIRTUEMART_PRODUCT_SALESPRICE';
else $label = 'COM_VIRTUEMART_CHILD_PRODUCT_SALESPRICE';
echo $currency->createPriceDiv ('salesPrice', $label, $product->prices);

Jörgen

Hello Patrick

I get the idea.
But if I don´t use the plugin, it would give the same effekt if I just check if it has children, right? The parents price must of course be set to the lowest child price before this.

regards

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Studio 42

Perhaps you can return right price from customfields sublayout, but i think you need perhaps to modify core file for this, i don't have check, because i prefer use my plugin, it's simpler for me because core file do not permit to have conditional layout render.

PRO

Quote from: brooklynbase on February 22, 2016, 17:56:46 PM


In the product list, the parent product (not orderable)



   <?php if (!$product->orderable){echo'From ';} ?>

Jörgen

Hello Pro

Great idea, thank You. Now I just have to see if the product has a parent id, in that case it is a child product. This makes me take out a unneccesary query from my templates :)

regards

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

Studio 42

In all case, Pro solution do not solve price from child, but can be a partial solution, but he's code give php error warning in all case.

PRO

Quote from: Studio 42 on May 11, 2016, 14:26:50 PM
but he's code give php error warning in all case.


<?php if ($product->orderable !=1){echo 'From ';} ?>

Uglystick

@Jorgen this would be a life saver if you can get this to work.

Jörgen

@Uglystick
I have the skeleton working for this right now. I use it to hide the stock and SKU for a parent item. I could publish my code, but I don´t really have the time to do it this week. PM me if I forget to do it next week.

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.