Delivery vmpsplugin.php failure to display value if Free

Started by AH, November 06, 2013, 19:34:22 PM

Previous topic - Next topic

AH

administrator\components\com_virtuemart\plugins\vmpsplugin.php


When using the shipping plugin the Free option results in nothing being returned to the view

This is particulary confusing for the customer

However because so many people are using this, it is difficult to change as returning 0.00 would  mess up their cart displays

A solution to this is as follows

Adjust the code to return a <span> class of "zero"  or whatever you prefer

if ($pluginSalesPrice) {
$costDisplay = $currency->priceDisplay ($pluginSalesPrice);
$costDisplay = '<span class="' . $this->_type . '_cost"> (' . JText::_ ('COM_VIRTUEMART_PLUGIN_COST_DISPLAY') . $costDisplay . " )</span>";
//quorvia added this custom element to deal with shipping free over a specified value.
} else {
            $costDisplay = '<span class="zero_' . $this->_type . '_cost"></span>';
        }



Then people can use CSS to determine what happens , I have chosen the very poor hard coded language, but I could have as easily put 0.00



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



It might be simpler just to start returning the 0.00 so a template override could be applied based on 0.00 - but apparently Alatak thinks that it once did this and the "return nothing" method was implemented.
Regards
A

Joomla 3.10.11
php 8.0

GJC Web Design

perhaps better in the template over ride ?

I always use this..

components/com_virtuemart/views/cart/tmpl/default_pricelist.php around line 334 on the default template

or better

templates/YOUR_TEMPLATE/html/com_virtuemart/cart/default_pricelist.php

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


GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

AH

GJC

Your solution is fine for the display of a value when a delivery rate is selected

I use :-


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

        </td>




But the problem is that
$this->cart->pricesUnformatted['salesPriceShipment']   will be empty until a payment method has been selected

This is where the customer confusion starts, as any delivery options that are FREE show nothing and have no variable passed to be able to test against.  Non free methods get a value -

$shipment_shipment_rate is a "block of text"

select_shipment.php

<?php
   echo 
"<fieldset>\n";
// if only one Shipment , should be checked by default
    foreach ($this->shipments_shipment_rates as $shipment_shipment_rates) {
if (is_array($shipment_shipment_rates)) {
    foreach ($shipment_shipment_rates as $shipment_shipment_rate) {
echo $shipment_shipment_rate."<br />\n";
    }
}
    }
    echo "</fieldset>\n";
    } else {
 echo "<h".$headerLevel.">".$this->shipment_not_found_text."</h".$headerLevel.">";
    }


Consequently I think that there is a need to return something in order to manage a display of "Free" or "0.00" rather than just having only the name returned.

Regards
A

Joomla 3.10.11
php 8.0

GJC Web Design

Yes - I understand what you mean -
I think it would be better as you suggest that a standard value is returned for a no cost value that all ship plug devs could use..

In my shipping plugs I always return a free flag of some sort with cookies and method in the getCosts()

then over ride the   protected function renderPluginName ($plugin) and set the free text as a label

there's no 0.00 in the cart but at least there is feedback for the customer that they are getting free shipping


[attachment cleanup by admin]
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

AH

GJC

My solution means no cookies and the option to render something with CSS but I can see why a new plugin would cater for the return data in a different way.

But the "default_pricelist.php"   should cater for a user defined message for a price when Free, not just return a Name.

As I doubt this will ever make the roadmap, I am happy to stick with my current solution.
Regards
A

Joomla 3.10.11
php 8.0

GJC Web Design

Yes of course - there's different ways to do this...  :)

Just a shame something can't be done at the vmpsplugin.php level in the next release that plugin builders could use to trigger e.g Free or Error or legit cost.

Any ship plugin that calls externally for it's rates always has the possibility of a failure and it requires quite an extra load of code to handle this (OK - it can be done at checkConditions() stage but it means calling getCosts() there - sort of a precheck)

Cheers
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation