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

Shopping cart not displaying totals

Started by FranzFromFar, December 20, 2017, 05:15:02 AM

Previous topic - Next topic

FranzFromFar

Hi,
I'm having some troubles configuring a cart in vm 3.0.12, since it's not displaying total (and product total).
It's just displaying product prices and quantity, but in the invoices the total is correct.
I had to copy the display_pricelist.php file from com_virtuemart/views folder to template/html folder, because even the product price was empty before copying the file.

This is actually the file


<fieldset class="vm-fieldset-pricelist">
<table
class="cart-summary"
cellspacing="0"
cellpadding="0"
border="0"
width="100%">
<tr>
<th class="vm-cart-item-name" ><?php echo vmText::('COM_VIRTUEMART_CART_NAME'?></th>
<!-- <th class="vm-cart-item-sku" ><?php echo vmText::('COM_VIRTUEMART_CART_SKU'?></th> -->
<th class="vm-cart-item-basicprice" ><?php echo vmText::('COM_VIRTUEMART_CART_PRICE'?></th>
<th class="vm-cart-item-quantity" ><?php echo vmText::('COM_VIRTUEMART_CART_QUANTITY'?></th>

<?php if (VmConfig::get ('show_tax')) {
$tax vmText::('COM_VIRTUEMART_CART_SUBTOTAL_TAX_AMOUNT');
if(!empty($this->cart->cartData['VatTax'])){
if(count($this->cart->cartData['VatTax']) < 2) {
reset($this->cart->cartData['VatTax']);
$taxd current($this->cart->cartData['VatTax']);
$tax shopFunctionsF::getTaxNameWithValue($taxd['calc_name'],$taxd['calc_value']);
}
}
?>

<th class="vm-cart-item-tax" ><?php echo "<span  class='priceColor2'>" $tax '</span>' ?></th>
<?php ?>
<!-- <th class="vm-cart-item-discount" ><?php echo "<span  class='priceColor2'>" vmText::('COM_VIRTUEMART_CART_SUBTOTAL_DISCOUNT_AMOUNT') . '</span>' ?></th> -->
<th class="vm-cart-item-total" ><?php echo vmText::('COM_VIRTUEMART_CART_TOTAL'?></th>
</tr>

<?php
$i 
1;

foreach (
$this->cart->products as $pkey => $prow) {
$prow->prices array_merge($prow->prices,$this->cart->cartPrices[$pkey]);
?>


<tr valign="top" class="sectiontableentry<?php echo $i ?>">
<input type="hidden" name="cartpos[]" value="<?php echo $pkey ?>">
<td class="vm-cart-item-name" >
<?php if ($prow->virtuemart_media_id) { ?>
<span class="cart-images">
<?php
if (!empty($prow->images[0])) {
echo $prow->images[0]->displayMediaThumb (''FALSE);
}
?>

</span>
<?php ?>
<?php echo JHtml::link ($prow->url$prow->product_name);
echo $this->customfieldsModel->CustomsFieldCartDisplay ($prow);
 ?>


</td>
<!-- <td class="vm-cart-item-sku" ><?php  echo $prow->product_sku ?></td> -->
<td class="vm-cart-item-basicprice" >
<?php
if (VmConfig::get ('checkout_show_origprice'1) && $prow->prices['basePriceWithTax'] != $prow->prices['basePriceWithTax']) {
echo '<span class="line-through">' $this->currencyDisplay->createPriceDiv ('basePriceVariant'''$prow->pricesTRUEFALSE) . '</span><br />';
}

if ($prow->prices['basePriceWithTax']) {
echo $this->currencyDisplay->createPriceDiv ('basePriceWithTax'''$prow->pricesFALSEFALSE1.0falsetrue);
} else {
echo $this->currencyDisplay->createPriceDiv ('basePriceVariant'''$prow->pricesFALSEFALSE1.0falsetrue);
}
?>

</td>
<td class="vm-cart-item-quantity" ><?php

if ($prow->step_order_level)
$step=$prow->step_order_level;
else
$step=1;
if($step==0)
$step=1;
?>

   <input type="text"
   onblur="Virtuemart.checkQuantity(this,<?php echo $step?>,'<?php echo vmText::('COM_VIRTUEMART_WRONG_AMOUNT_ADDED',true)?>');"
   onclick="Virtuemart.checkQuantity(this,<?php echo $step?>,'<?php echo vmText::('COM_VIRTUEMART_WRONG_AMOUNT_ADDED',true)?>');"
   onchange="Virtuemart.checkQuantity(this,<?php echo $step?>,'<?php echo vmText::('COM_VIRTUEMART_WRONG_AMOUNT_ADDED',true)?>');"
   onsubmit="Virtuemart.checkQuantity(this,<?php echo $step?>,'<?php echo vmText::('COM_VIRTUEMART_WRONG_AMOUNT_ADDED',true)?>');"
   title="<?php echo  vmText::_('COM_VIRTUEMART_CART_UPDATE'?>" class="quantity-input js-recalculate" size="3" maxlength="4" name="quantity[<?php echo $pkey?>]" value="<?php echo $prow->quantity ?>" />

<button type="submit" class="vmicon vm2-add_quantity_cart" name="updatecart.<?php echo $pkey ?>" title="<?php echo  vmText::('COM_VIRTUEMART_CART_UPDATE'?>" ></button>

<button type="submit" class="vmicon vm2-remove_from_cart" name="delete.<?php echo $pkey ?>" title="<?php echo vmText::('COM_VIRTUEMART_CART_DELETE'?>" ></button>
</td>

<?php if (VmConfig::get ('show_tax')) { ?>
<td class="vm-cart-item-tax" ><?php echo "<span class='priceColor2'>" $this->currencyDisplay->createPriceDiv ('taxAmount'''$prow->pricesFALSEFALSE$prow->quantityfalsetrue) . "</span>" ?></td>
<?php ?>

<td class="vm-cart-item-total">
<?php //vmdebug('hm',$prow->prices,$this->cart->cartPrices[$pkey]);
if (VmConfig::get ('checkout_show_origprice'1) && !empty($prow->prices['basePriceWithTax']) && $prow->prices['basePriceWithTax'] != $prow->prices['salesPrice']) {
echo '<span class="line-through">' $this->currencyDisplay->createPriceDiv ('basePriceWithTax'''$prow->pricesTRUEFALSE$prow->quantity) . '</span><br />';
}
elseif (VmConfig::get ('checkout_show_origprice'1) && empty($prow->prices['basePriceWithTax']) && $prow->prices['basePriceVariant'] != $prow->prices['salesPrice']) {
echo '<span class="line-through">' $this->currencyDisplay->createPriceDiv ('basePriceVariant'''$prow->pricesTRUEFALSE$prow->quantity) . '</span><br />';
}
echo $this->currencyDisplay->createPriceDiv ('salesPrice'''$prow->pricesFALSEFALSE$prow->quantity?>
</td>
</tr>
<?php
$i = ($i==1) ? 1;
?>

<!--Begin of SubTotal, Tax, Shipment, Coupon Discount and Total listing -->
<?php if (VmConfig::get ('show_tax')) {
$colspan 3;
} else {
$colspan 2;
?>

<tr>
<td colspan="4">&nbsp;</td>

<td colspan="<?php echo $colspan ?>">
<hr/>
</td>
</tr>
<tr class="sectiontableentry1">
<td colspan="4" align="right"><?php echo vmText::('COM_VIRTUEMART_ORDER_PRINT_PRODUCT_PRICES_TOTAL'); ?></td>

<?php if (VmConfig::get ('show_tax')) { ?>
<td align="right"><?php echo "<span  class='priceColor2'>" $this->currencyDisplay->createPriceDiv ('taxAmount'''$this->cart->cartPricesFALSEfalsetrue) . "</span>" ?></td>
<?php ?>
<td align="right"><?php echo $this->currencyDisplay->createPriceDiv ('salesPrice'''$this->cart->cartPricesFALSE?></td>
</tr>

<?php
if (VmConfig::get ('coupons_enable')) {
?>

<?php if (VmConfig::get ('show_tax')) {
$colspan 3;
} else {
$colspan 2;
?>


</tr>
<?php ?>
<?php
foreach ($this->cart->cartData['DBTaxRulesBill'] as $rule) {
?>

<tr class="sectiontableentry<?php echo $i ?>">
<td colspan="4" align="right"><?php echo $rule['calc_name'?> </td>

<?php if (VmConfig::get ('show_tax')) { ?>
<td align="right"></td>
<?php ?>
<td align="right"><?php echo $this->currencyDisplay->createPriceDiv ($rule['virtuemart_calc_id'] . 'Diff'''$this->cart->cartPrices[$rule['virtuemart_calc_id'] . 'Diff'], FALSE); ?></td>
<td align="right"><?php echo $this->currencyDisplay->createPriceDiv ($rule['virtuemart_calc_id'] . 'Diff'''$this->cart->cartPrices[$rule['virtuemart_calc_id'] . 'Diff'], FALSE); ?> </td>
</tr>
<?php
if (
$i) {
$i 1;
} else {
$i 0;
}
?>


<?php

foreach ($this->cart->cartData['taxRulesBill'] as $rule) {
if($rule['calc_value_mathop']=='avalara') continue;
?>

<tr class="sectiontableentry<?php echo $i ?>">
<td colspan="4" align="right"><?php echo $rule['calc_name'?> </td>
<?php if (VmConfig::get ('show_tax')) { ?>
<td align="right"><?php echo $this->currencyDisplay->createPriceDiv ($rule['virtuemart_calc_id'] . 'Diff'''$this->cart->cartPrices[$rule['virtuemart_calc_id'] . 'Diff'], FALSE); ?> </td>
<?php ?>
<td align="right"><?php ?> </td>
<td align="right"><?php echo $this->currencyDisplay->createPriceDiv ($rule['virtuemart_calc_id'] . 'Diff'''$this->cart->cartPrices[$rule['virtuemart_calc_id'] . 'Diff'], FALSE); ?> </td>
</tr>
<?php
if (
$i) {
$i 1;
} else {
$i 0;
}
}

foreach (
$this->cart->cartData['DATaxRulesBill'] as $rule) {
?>

<tr class="sectiontableentry<?php echo $i ?>">
<td colspan="4" align="right"><?php echo   $rule['calc_name'?> </td>

<?php if (VmConfig::get ('show_tax')) { ?>
<td align="right"></td>

<?php ?>
<td align="right"><?php echo $this->currencyDisplay->createPriceDiv ($rule['virtuemart_calc_id'] . 'Diff'''$this->cart->cartPrices[$rule['virtuemart_calc_id'] . 'Diff'], FALSE); ?>  </td>
<td align="right"><?php echo $this->currencyDisplay->createPriceDiv ($rule['virtuemart_calc_id'] . 'Diff'''$this->cart->cartPrices[$rule['virtuemart_calc_id'] . 'Diff'], FALSE); ?> </td>
</tr>
<?php
if (
$i) {
$i 1;
} else {
$i 0;
}
}

if ( 
VmConfig::get('oncheckout_opc',true) or
!VmConfig::get('oncheckout_show_steps',false) or
(!VmConfig::get('oncheckout_opc',true) and VmConfig::get('oncheckout_show_steps',false) and
!empty($this->cart->virtuemart_shipmentmethod_id) )
) { 
?>

<tr class="sectiontableentry1" style="vertical-align:top;">
<?php if (!$this->cart->automaticSelectedShipment) { ?>
<td colspan="4" style="align:left;vertical-align:top;">
<?php
echo '<h3>'.vmText::('COM_VIRTUEMART_CART_SELECTED_SHIPMENT').'</h3>';
echo $this->cart->cartData['shipmentName'].'<br/>';

if (!empty($this->layoutName) and $this->layoutName == 'default') {
if (VmConfig::get('oncheckout_opc'0)) {
$previouslayout $this->setLayout('select');
echo $this->loadTemplate('shipment');
$this->setLayout($previouslayout);
} else {
echo JHtml::_('link'JRoute::_('index.php?option=com_virtuemart&view=cart&task=edit_shipment'$this->useXHTML$this->useSSL), $this->select_shipment_text'class=""');
}
} else {
echo vmText::('COM_VIRTUEMART_CART_SHIPPING');
}
echo '</td>';
} else {
?>

<td colspan="4" style="align:left;vertical-align:top;">
<?php echo '<h4>'.vmText::('COM_VIRTUEMART_CART_SELECTED_SHIPMENT').'</h4>'?>
<?php echo $this->cart->cartData['shipmentName']; ?>
</td>
<?php ?>

<?php if (VmConfig::get ('show_tax')) { ?>
<td align="right"><?php echo "<span  class='priceColor2'>" $this->currencyDisplay->createPriceDiv ('shipmentTax'''$this->cart->cartPrices['shipmentTax'], FALSE) . "</span>"?> </td>
<?php ?>
<td align="right"><?php if($this->cart->cartPrices['salesPriceShipment'] < 0) echo $this->currencyDisplay->createPriceDiv ('salesPriceShipment'''$this->cart->cartPrices['salesPriceShipment'], FALSE); ?></td>
<td align="right"><?php echo $this->currencyDisplay->createPriceDiv ('salesPriceShipment'''$this->cart->cartPrices['salesPriceShipment'], FALSE); ?> </td>
</tr>
<?php ?>
<?php if ($this->cart->pricesUnformatted['salesPrice']>0.0 and
VmConfig::get('oncheckout_opc',true) or
!VmConfig::get('oncheckout_show_steps',false) or
( (!VmConfig::get('oncheckout_opc',true) and VmConfig::get('oncheckout_show_steps',false) ) and !empty($this->cart->virtuemart_paymentmethod_id))
)
) { 
?>

<tr class="sectiontableentry1" style="vertical-align:top;">
<?php if (!$this->cart->automaticSelectedPayment) { ?>
<td colspan="4" style="align:left;vertical-align:top;">
<?php
echo '<h3>'.vmText::('COM_VIRTUEMART_CART_SELECTED_PAYMENT').'</h3>';
echo $this->cart->cartData['paymentName'].'<br/>';

if (!empty($this->layoutName) && $this->layoutName == 'default') {
if (VmConfig::get('oncheckout_opc'0)) {
$previouslayout $this->setLayout('select');
echo $this->loadTemplate('payment');
$this->setLayout($previouslayout);
} else {
echo JHtml::_('link'JRoute::_('index.php?option=com_virtuemart&view=cart&task=editpayment'$this->useXHTML$this->useSSL), $this->select_payment_text'class=""');
}
} else {
echo vmText::('COM_VIRTUEMART_CART_PAYMENT');
?>
</td>

<?php } else { ?>
<td colspan="4" style="align:left;vertical-align:top;" >
<?php echo '<h4>'.vmText::('COM_VIRTUEMART_CART_SELECTED_PAYMENT').'</h4>'?>
<?php echo $this->cart->cartData['paymentName']; ?> </td>
<?php ?>
<?php if (VmConfig::get ('show_tax')) { ?>
<td align="right"><?php echo "<span  class='priceColor2'>" $this->currencyDisplay->createPriceDiv ('paymentTax'''$this->cart->cartPrices['paymentTax'], FALSE) . "</span>"?> </td>
<?php ?>
<td align="right" ><?php if($this->cart->cartPrices['salesPricePayment'] < 0) echo $this->currencyDisplay->createPriceDiv ('salesPricePayment'''$this->cart->cartPrices['salesPricePayment'], FALSE); ?></td>
<td align="right" ><?php  echo $this->currencyDisplay->createPriceDiv ('salesPricePayment'''$this->cart->cartPrices['salesPricePayment'], FALSE); ?> </td>
</tr>
<?php  ?>
<tr>
<td colspan="4">&nbsp;</td>
<td colspan="<?php echo $colspan ?>">
<hr/>
</td>
</tr>
<tr class="sectiontableentry2">
<td colspan="4" align="right"><?php echo vmText::('COM_VIRTUEMART_CART_TOTAL'?>:</td>

<?php if (VmConfig::get ('show_tax')) { ?>
<td align="right"> <?php echo "<span  class='priceColor2'>" $this->currencyDisplay->createPriceDiv ('billTaxAmount'''$this->cart->cartPrices['billTaxAmount'], FALSE) . "</span>" ?> </td>
<?php ?>
<td align="right"><strong><?php echo $this->currencyDisplay->createPriceDiv ('billTotal'''$this->cart->cartPrices['billTotal'], FALSE); ?></strong></td>
</tr>
<?php
if ($this->totalInPaymentCurrency) {
?>


<tr class="sectiontableentry2">
<td colspan="4" align="right"><?php echo vmText::('COM_VIRTUEMART_CART_TOTAL_PAYMENT'?>:</td>

<?php if (VmConfig::get ('show_tax')) { ?>
<td align="right"></td>
<?php ?>
<td align="right"></td>
<td align="right"><strong><?php echo $this->totalInPaymentCurrency;   ?></strong></td>
</tr>
<?php
}

//Show VAT tax seperated
if(!empty($this->cart->cartData)){
if(!empty($this->cart->cartData['VatTax'])){
$c count($this->cart->cartData['VatTax']);
if (!VmConfig::get ('show_tax') or $c>1) {
if($c>0){
?>
<tr class="sectiontableentry2">
<td colspan="5" align="right"><?php echo vmText::('COM_VIRTUEMART_TOTAL_INCL_TAX'?></td>

<?php if (VmConfig::get ('show_tax')) { ?>
<td ></td>
<?php ?>
<td></td>
</tr><?php
}
foreach( $this->cart->cartData['VatTax'] as $vatTax ) {
if(!empty($vatTax['result'])) {
echo '<tr class="sectiontableentry'.$i.'">';
echo '<td colspan="4" align="right">'.shopFunctionsF::getTaxNameWithValue($vatTax['calc_name'],$vatTax['calc_value']). '</td>';
echo '<td align="right"><span class="priceColor2">'.$this->currencyDisplay->createPriceDiv'taxAmount'''$vatTax['result'], FALSEfalse1.0,false,true ).'</span></td>';
echo '<td></td><td></td>';
echo '</tr>';
}
}
}
}
}
?>


</table>
</fieldset>



I hope someone can help me :)
thanks in advance



FranzFromFar

Update: with the code modified as the post above, I'm able to display the product total but not the total bill.
I hope someone can help me :)

FranzFromFar

How can I display billTotal? I'm trying with echo ($data->billTotal), but it does not display anything...

jenkinhill

I guess you actually mean default_pricelist.php  not  display_pricelist.php  ?  If you had to copy the file to template/html/com_virtuemart then I guess (again) that you are using overrides - of which nobody here can have knowledge of, but does suggest you have a template issue.

Why are you using an old insecure VirtueMart version? See   http://forum.virtuemart.net/index.php?topic=118683.0

Current VM version is 3.2.10   
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

FranzFromFar

So, no way to solve? Any suggestion?
Thank you

Jörgen

Hello
You are given advise, but You do take them. You don´t give much information.

Why are You using an old and unsecure VM version ?

You obviously seem to use a custom template. Try with Protostar and see if it works. Then modify Your template. Or Contact Your template designer for an update.

Have You changed anything in the configuration of the prices in the back end?

regards

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

jenkinhill

You are using a VirtueMart that was released over 2 years ago.  It is insecure so should not be used on a live website.  Your first action should be to update VirtueMart. You probably also use an old insecure Joomla version so that should be updated, too.  No Joomla version before J3.8.2 is secure.

You appear to be using a template which has display problems - maybe it is incompatible with that VirtueMart version? That should also be updated, or use a new template.

Test all updates on a backup copy of the live site, assuming you have a live site that has not yet been hacked (you have provided so little information).
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum