how to dislay the shipping cost when the total cost is zero ?

Started by iwanna, June 17, 2014, 12:10:19 PM

Previous topic - Next topic

iwanna

Hello,

Could somebody help me with how can I dislay the shipping cost in the shipping method when the total shipping cost is free ?..
I want to display 0,00€, even if it is free.


jenkinhill

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


jenkinhill

Works OK for me, VM2.6.6  Make sure you don't have a minimum value price set for your shipping plugin.
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

GJC Web Design

Jenks, assume you mean the Shipment Cost - set to 0.001  ?

just tried in 2.6.6 /std templates - also just shows blank on a blank weight/postcode  plugin except for Shipment Cost = 0.001

did this always work do u know?


In my shipping plugins I over write the  protected function renderPluginName ($plugin) in the actual plugin to provide a free label and 0.00€  etc -

You can try that approach in what ever shipping plugin you r using

or hack the core vmsplug.php to do this

otherwise it is in every template that display shipping costs do some code

if(!$shippingcost){
echo '0.00€
}else{
echo $shippingcost;
}
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

iwanna

well, I did tried what jenkinhill said (same version: VirtueMart 2.6.6) but nothing.  :-\

And I did read your last reply GJC Web Design but I didn't understand much  :-\..

I found in /public_html/administrator/components/com_virtuemart/plugins/vmpsplugin.php

protected function renderPluginName ($plugin) {

$return = '';
$plugin_name = $this->_psType . '_name';
$plugin_desc = $this->_psType . '_desc';
$description = '';
// $params = new JParameter($plugin->$plugin_params);
// $logo = $params->get($this->_psType . '_logos');
$logosFieldName = $this->_psType . '_logos';
$logos = $plugin->$logosFieldName;
if (!empty($logos)) {
$return = $this->displayLogos ($logos) . ' ';
}
if (!empty($plugin->$plugin_desc)) {
$description = '<span class="' . $this->_type . '_description">' . $plugin->$plugin_desc . '</span>';
}
$pluginName = $return . '<span class="' . $this->_type . '_name">' . $plugin->$plugin_name . '</span>' . $description;
return $pluginName;
}


I don't understand what I have to change in the code  :-\

jenkinhill

I set the product price to 0.001 using a price override - to show the product price as 0.00 and prevent the "call for pricing" being displayed . That is what I have always done and the standard shipping module works OK with the Minimum order amount left empty, but according to some discussions a long time back, some third party shipping plugins also seem to require a figure of 0.001 for the Minimum order amount.
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

GJC Web Design

but what if the product price is something and the free shipping is just because of the total or under a weight etc?

Or is the wrong end of the stick being accessed?
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

GJC Web Design

@iwanna - as I say - it isn't for the faint hearted - you need to know a good wodge of php and how functions work etc



in your case I think this way would be simpler

Quote
otherwise it is in every template that display shipping costs do some code

if(!$shippingcost){
echo '0.00&euro;
}else{
echo $shippingcost;
}
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

The issue as most of us know is that the code returns absolutely nothing when the cost of shipping is 0

Many people put the product weight to 0 to get Free shipping and that works well except for the pesky lack of any output from the shipping code.

This is not ideal (LMAO)

Set shipping weight to 0

Then get some form of output from shipping (note as GJC said - gettting a value of 0.00 is much harder than it looks as other code is involved)

Here is my solution (FWIW):-

administrator\components\com_virtuemart\plugins\vmpsplugin.php

Get it to spit something out

Existing code returns nothing

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

$pluginmethod_id = $this->_idName;
$pluginName = $this->_psType . '_name';
if ($selectedPlugin == $plugin->$pluginmethod_id) {
$checked = 'checked="checked"';
} else {
$checked = '';
}

if (!class_exists ('CurrencyDisplay')) {
require(JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php');
}
$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;
}




This returns 0.00


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

$pluginmethod_id = $this->_idName;
$pluginName = $this->_psType . '_name';
if ($selectedPlugin == $plugin->$pluginmethod_id) {
$checked = 'checked="checked"';
} else {
$checked = '';
}

if (!class_exists ('CurrencyDisplay')) {
require(JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php');
}
$currency = CurrencyDisplay::getInstance ();
$costDisplay = "";
if ($pluginSalesPrice) {
$costDisplay = $currency->priceDisplay ($pluginSalesPrice);
$costDisplay = '<span class="' . $this->_type . '_cost"> (' . JText::_ ('COM_VIRTUEMART_PLUGIN_COST_DISPLAY') . $costDisplay . ")</span>";
        } else { //quorvia added this custom element to deal with shipping free over a specified value.
            $costDisplay = '<span class="zero_' . $this->_type . '_cost">0.00</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;
}




Regards
A

Joomla 4.4.5
php 8.1

jenkinhill

I got the wrong end of the stick - I read it as trigger shipping charge for free items.
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

GJC Web Design

Hutsons code will work and to save core hacking you can just paste that function into the shipping plug .php file and it should simply over ride
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

 8)

I core hacked maybe I should have moved it into the plugin (not sure what that means) but I will have a look
Regards
A

Joomla 4.4.5
php 8.1

GJC Web Design

just paste the complete function in the bottom of e.g. plugins/vmshipment/weight_countries/weight_countries.php

should be picked up as an over ride (of couse in this case will get over written when the AIO is updated - but you could just rename everything so it's a unique plugin)
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

Thanks for information, I am never going to get very proficient in PHP unless I spend time studying

I did move this function into a shipping plugin I developed to use and it works fine.

I want to keep an eye on core code for shipping, so am going to re-apply the "adjustment"  to core code


I had tried to get alatak to include it in core, but apparently returning nothing when a $pluginSalesPrice is 0 was a wanted feature. Go figure

Thanks again for your help.
Regards
A

Joomla 4.4.5
php 8.1