Author Topic: Delivery vmpsplugin.php failure to display value if Free  (Read 3855 times)

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3172
  • VirtueMart Version: 3.8.2
Delivery vmpsplugin.php failure to display value if Free
« on: November 06, 2013, 19:34:22 pm »
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

Code: [Select]
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

Code: [Select]

.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.9.18
php 7.3

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 9653
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: Delivery vmpsplugin.php failure to display value if Free
« Reply #1 on: November 06, 2013, 22:34:53 pm »
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

Code: [Select]
<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 http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3172
  • VirtueMart Version: 3.8.2
Re: Delivery vmpsplugin.php failure to display value if Free
« Reply #2 on: November 07, 2013, 00:23:01 am »
GJC

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

I use :-

Code: [Select]
<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

Code: [Select]
<?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.9.18
php 7.3

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 9653
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: Delivery vmpsplugin.php failure to display value if Free
« Reply #3 on: November 07, 2013, 00:43:46 am »
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 http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

AH

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 3172
  • VirtueMart Version: 3.8.2
Re: Delivery vmpsplugin.php failure to display value if Free
« Reply #4 on: November 07, 2013, 09:38:35 am »
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.9.18
php 7.3

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 9653
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 3.6.8
Re: Delivery vmpsplugin.php failure to display value if Free
« Reply #5 on: November 07, 2013, 10:12:45 am »
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 http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 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
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation