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

Multiple product quantity by custom field value

Started by BKintera, January 14, 2016, 17:37:47 PM

Previous topic - Next topic

BKintera

Hi everyone,

My client wants more columns in cart view, and those columns should have values of custom fields and some columns need to show product quantity * customfield value.

For example, product is "Package of Egg boxes", one package of Egg boxes have 500 egg boxes and when someone add to cart 2 packages of Egg Boxes in cart view there should be column "Transport package (pcs)" and number 1.000 in that column.

You can see product details page here:

http://panapac.moderanweb.rs/en/products/menu-boxes/menu-box-mb-1-orange-panapac

3 out of 4 customfields from product details page should be in cart view as well (Primary package(pcs),  Transport package (pcs) and Transport package (m³))

I have managed to add column "Transport package (m³):" in cart view, so I know how to edit cart view and add more columns, but I'm not satisfied how I did this, and here is why, this is my code in override of default_pricelist.php file:


<td class="zapremina">
        <?php
            
if ($prow->category_name == 'Egg boxes' || $prow->category_name == 'Kutije za jaja') {
                echo 
'<span class="kubikaza">' $prow->quantity 0.2 '</span>';
            }
            if (
$prow->category_name == 'Menu boxes' || $prow->category_name == 'Kutije za hranu') {
                echo 
'<span class="kubikaza">' $prow->quantity 0.205 '</span>';
            }
            
            if (
$prow->product_name == 'Tacna - T 073 Crna' || $prow->product_name == 'Tray - T 073 Black' || $prow->product_name == 'Tacna - T 073 Bela' || $prow->product_name == 'Tray - T 073 White') {
                echo 
'<span class="kubikaza">' $prow->quantity 0.125 '</span>';
            }
            if (
$prow->product_name == 'Tacna - T 073A Crna' || $prow->product_name == 'Tray - T 073A Black' || $prow->product_name == 'Tacna - T 073A Bela' || $prow->product_name == 'Tray - T 073A White') {
                echo 
'<span class="kubikaza">' $prow->quantity 0.130 '</span>';
            }
            if (
$prow->product_name == 'Tacna - T 168 Bela' || $prow->product_name == 'Tray - T 168 White') {
                echo 
'<span class="kubikaza">' $prow->quantity 0.170 '</span>';
            }
        
?>

    </td>



So, as you can see, instead of few simple lines of code like:


<td class="zapremina">
        <?php echo '<span class="kubikaza">' $prow->quantity * [b]customfield value[/b] . '</span>'?>
</td>


I had to add many if statements to target only products with 0.2m3 or 0.13m3 etc. and that is ok for now, but there will be more and more products.


My question is:

How can I call customfield value, so I dont need to use so many if statements?

P.S. As you can probably see my php knowladge isn't so good.


Joomla 3.4.7
VirtueMart 3.0.12


Thanks in advance,
Milan