VM 2.6.8. Very bad code in plugin vmshipment-weight_countries

Started by Wedal, August 18, 2014, 07:12:02 AM

Previous topic - Next topic

Wedal

VM 2.6.8.
File: plugins/vmshipment/weight_countries/weight_countries/tmpl/default.php

Code:

<?php

//vmdebug('we have here ',$viewData['product']->prices,$viewData['method']);
$currency $viewData['currency'];
if(!empty(
$viewData['method']->countries) and is_array($viewData['method']->countries) and count($viewData['method']->countries)>0){
$countryM VmModel::getModel('country');
echo 'We ship to ';
foreach($viewData['method']->countries as $virtuemart_country_id){
$country $countryM->getData($virtuemart_country_id);
echo $country->country_name;
//vmdebug('my country ',$country);
}
}
echo 
'</br>';
echo 
'With shipment '.$viewData['method']->shipment_name.' for '.$currency->priceDisplay($viewData['product']->prices['shipmentPrice']);

?>



Result in productdetail page:

<div class="spacer-buy-area">
<br>
                    With shipment Почтой России &ndash; вся Россия for 490 руб
                <br>

<div class="addtocart-area">
............................................


A few facts:

  • This line will appear on all sites using standard shipping after the upgrade to VM 2.6.8.
  • This line can not be hidden by CSS.
  • This line can not be removed without hacking the plugin, since the layout of this plugin is not overridden.

Guys, how was it possible to write such bad code? Sorry.

jenkinhill

For those who do not want the shipment method/cost display it is simple to use a template override. http://forum.virtuemart.net/index.php?topic=125307.msg428964 
No hacking required.
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

Milbo

yepp and the option is already added in svn. A small mistake, either the layouts dont support it anyways or you can use a simple empty file as override.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

philraymond

But if you're already using a 3rd party template that's overriding the file, and you make the edits in that override, then when you update the template, it gets overridden right? What is best practice in that case?

(If the devs could just wrap the shipment display in a css class, it would be a much easier override with display: none).

Thanks,
Phil

GJC Web Design

the template update can't over write a file that doesn't exist in it's update.. the instruction is to make a new file.. it will remain unless your "update" deletes everything before updating - highly unlikely
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

Milbo

and anyway, I added an option, so you can disable the shipment prices in the productdetails by a simple click.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

philraymond

Quote from: Milbo on November 23, 2014, 13:24:44 PM
and anyway, I added an option, so you can disable the shipment prices in the productdetails by a simple click.

Ah yes, I see that now. Thank you very much. (For anyone else looking for it, it's under each shipment method's configuration page.)