VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: Wedal on August 18, 2014, 07:12:02 AM

Title: VM 2.6.8. Very bad code in plugin vmshipment-weight_countries
Post by: Wedal on August 18, 2014, 07:12:02 AM
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:

Guys, how was it possible to write such bad code? Sorry.
Title: Re: VM 2.6.8. Very bad code in plugin vmshipment-weight_countries
Post by: jenkinhill on August 18, 2014, 10:43:12 AM
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.
Title: Re: VM 2.6.8. Very bad code in plugin vmshipment-weight_countries
Post by: Milbo on August 18, 2014, 19:50:41 PM
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.
Title: Re: VM 2.6.8. Very bad code in plugin vmshipment-weight_countries
Post by: philraymond on November 20, 2014, 11:50:27 AM
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
Title: Re: VM 2.6.8. Very bad code in plugin vmshipment-weight_countries
Post by: GJC Web Design on November 20, 2014, 11:54:23 AM
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
Title: Re: VM 2.6.8. Very bad code in plugin vmshipment-weight_countries
Post by: 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.
Title: Re: VM 2.6.8. Very bad code in plugin vmshipment-weight_countries
Post by: philraymond on December 01, 2014, 17:38:59 PM
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.)