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

Minimum Amount for Free Shipment - Option has no value solution/hack

Started by AH, October 17, 2013, 15:03:33 PM

Previous topic - Next topic

AH

VM 2.0.24

When a cart is eligible for 0 price shipping based on the value of the items in the cart (free shipping) We can configure the shipment method using the option Minimum Amount for Free Shipment.

Great feature BUT the cost of the shipping is not returned only the name of the Shipment method and that can be confusing for shoppers.

In site\administrator\components\com_virtuemart\plugins\vmpsplugin.php possible methods and rates display controlled by function getPluginHtml



$currency = CurrencyDisplay::getInstance ();
$costDisplay = "";
if ($pluginSalesPrice) {
$costDisplay = $currency->priceDisplay ($pluginSalesPrice);
$costDisplay = '<span class="' . $this->_type . '_cost"> (' . JText::_ ('COM_VIRTUEMART_PLUGIN_COST_DISPLAY') . $costDisplay . " )</span>";
               }

$html = '<input type="radio" name="' . $pluginmethod_id . '" id="' . $this->_psType . '_id_' . $plugin->$pluginmethod_id . '"   value="' . $plugin->$pluginmethod_id . '" ' . $checked . ">\n"
. '<label for="' . $this->_psType . '_id_' . $plugin->$pluginmethod_id . '">' . '<span class="' . $this->_type . '">' . $plugin->$pluginName . $costDisplay . "</span></label>\n";

return $html;
}


$pluginSalePrice is not set for shipping methods that qualify for free shipping based on the -Minimum Amount for Free Shipment.

We just get back the payment name in html format.  Nothing to change in the VIEW using an override, because we have nothing to manage.  :(

So change administrator\components\com_virtuemart\plugins\vmpsplugin.php (but it will get overwritten in an update!!) to return (at least) a span element for the 0 cost (if you are making the change you could add your own (non multi lingual) text as well.

      if ($pluginSalesPrice) {
         $costDisplay = $currency->priceDisplay ($pluginSalesPrice);
         $costDisplay = '<span class="' . $this->_type . '_cost"> (' . JText::_ ('COM_VIRTUEMART_PLUGIN_COST_DISPLAY') . $costDisplay . " )</span>";
//added this custom element to create a <span> value for 0 cost methods.
      } else {
            $costDisplay = '<span class="zero_' . $this->_type . '_cost"></span>';
        }


It is up to you what you then do with this span (a new text variable is preferable but the span would be a start for existing sites- hmmm!)

I am considering using css as below:-

.zero_vmshipment_cost:before {
    content:" Free shipping";
    font-weight:bold;
    color: #E36300;
    font-size:120%;
}




For the Cart chosen option - blank value IMHO is confusing

Create an Override to the default_pricelist.php:-

<td align="right">
            <?php if($this->cart->pricesUnformatted['salesPriceShipment'] > 0){
                echo 
$this->currencyDisplay->createPriceDiv ('salesPriceShipment'''$this->cart->pricesUnformatted['salesPriceShipment'], FALSE);
            } else {
                echo 
"<strong>Free Shipping</strong>";
            }
            
?>

        </td>


You could also add the text as a language Variable and manage accordingly.
Regards
A

Joomla 4.4.5
php 8.1