VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: gba on January 25, 2018, 15:10:24 PM

Title: Shipping cost 0 not visible in cart
Post by: gba on January 25, 2018, 15:10:24 PM
Hi all!
I noticed, that the shipping costs are rendered empty, if the value is 0 ():
$this->currencyDisplay->createPriceDiv ('salesPriceShipment', '', $this->cart->cartPrices['salesPriceShipment'], FALSE);
Why?
And how can I make VM render 0,00 [CurrSign] instead?
Thanks a lot in advance for any useful hint!
Kind regards,
Gerald
Title: Re: Shipping cost 0 not visible in cart
Post by: Jörgen on January 25, 2018, 15:34:17 PM
Try something like 0,0001

Regards

Jörgen @ Kreativ Fotografi
Title: Re: Shipping cost 0 not visible in cart
Post by: gba on January 25, 2018, 15:41:52 PM
Wow - how ugly! ;D
But it seems to work.
Couldn't this cause rounding problems somewhere?
And most interesting:
Why does VM take the decision to display no amount at all on a price being 0 - shouldn't the layout creator be able to decide that?
Title: Re: Shipping cost 0 not visible in cart
Post by: AH on January 25, 2018, 17:45:18 PM
Yes it is a shame that there is not a choice to display 0

This is controlled by :

\administrator\components\com_virtuemart\plugins\vmpsplugin.php

protected function getPluginHtml ($plugin, $selectedPlugin, $pluginSalesPrice) {


if ($pluginSalesPrice) {

existing code


} else { //added this custom element to deal with shipping free.
         $costDisplay = '<span class="zero_' . $this->_type . '_cost">0.00</span>';
      }


I added the "else" clause
Title: Re: Shipping cost 0 not visible in cart
Post by: gba on January 25, 2018, 19:09:29 PM
Hi!
Thank you for that hack.
Actually I am not fond of core hacks as they mean big expense updating VM.
What does the VM team think about that issue?
Title: Re: Shipping cost 0 not visible in cart
Post by: Jörgen on January 25, 2018, 19:58:09 PM
Hello

If You make the "cost" small enough it will not show. Rounding to 2 decimals makes sure of that.

regards

Jörgen @ Kreativ Fotografi
Title: Re: Shipping cost 0 not visible in cart
Post by: AH on January 25, 2018, 21:32:33 PM
@joergens solution does function

But a value for shipping will be stored for shipping charges in your tables

I personally don't like doing this as the value gets passed to our accounting platform and reported - no matter how small