VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: Cococoder on January 09, 2018, 11:06:16 AM

Title: [SOLVED] Shipment method in product view display issue
Post by: Cococoder on January 09, 2018, 11:06:16 AM
Hi guys,

VirtueMart 3.2.10
Joomla! 3.8.3 Stable
PHP: 7.1.12

NOTE: same error with same config on PHP 7.0 on another site.


Effect: instead of the shipment method, a letter is displayed. It use to work fine. Link gives you a live example: https://store.seobytes.eu/index.php/en/product-variants/multi-variant-detail

Shipment methods display correctly in the cart page.

Trouble shooting steps taken so far:
Try with default beez template and clearing cache (no changes)
Try on two different sites (same issue)
Delete Shipment method and create new ones and clearing cache (no changes)

Any suggestion or help welcome.
Title: Re: Shipment method in product view display issue
Post by: Jörgen on January 09, 2018, 11:27:09 AM
Does the W disappear when You disable the display of the shipment cost in Product details ?

This could be displayed from Your shipping plugin.

Check the code for the plugin.

regards

Jörgen @ Kreativ Fotografi
Title: Re: Shipment method in product view display issue
Post by: Cococoder on January 09, 2018, 12:37:11 PM
No it does appear when it is enabled.
I am using the defaut weight zip code plugin
So far I did not find where this W comes from.
The product display (htdocs\components\com_virtuemart\views\productdetails) code is as follow:
<?php
      echo shopFunctionsF::renderVmSubLayout('rating', array('showRating' => $this->showRating, 'product' => $this->product));

      $productDisplayTypes = array('productDisplayShipments', 'productDisplayPayments');
      foreach ($productDisplayTypes as $productDisplayType) {

         if(empty($this->$productDisplayType)){
            continue;
         } else if (!is_array($this->$productDisplayType)) {
            $this->$productDisplayType = array($this->$productDisplayType);
         }

         foreach ($this->$productDisplayType as $productDisplay) {

            if(empty($productDisplay)){
               continue;
            } else if (!is_array($productDisplay)){
               $productDisplay = array($productDisplay);
            }

            foreach ($productDisplay as $virtuemart_method_id =>$productDisplayHtml) {
               ?>
               <div class="<?php echo substr($productDisplayType, 0, -1) ?> <?php echo substr($productDisplayType, 0, -1).'-'.$virtuemart_method_id ?>">
                  <?php
                  echo $productDisplayHtml;
                  ?>
               </div>
               <?php
            }
         }
      }

I assume the error is here echo substr($productDisplayType, 0, -1)  located in the div in the last foreach loop.
Title: Re: Shipment method in product view display issue
Post by: Jörgen on January 09, 2018, 12:57:37 PM
That code should work for everybody else.

I assume someone has accidentaly entered a W somewhere in ýour code or in the shipment method
Title: Re: Shipment method in product view display issue
Post by: Cococoder on January 09, 2018, 13:13:21 PM
Site is in english, product view and shipment method plugin not altered.
In my production site, letter appearing is different.
It seems the plugin does not fetch the proper data.
Issue persists even after complete virtuemart reset.
Title: Re: Shipment method in product view display issue
Post by: Cococoder on January 09, 2018, 13:33:37 PM
I just did a reset and use the beez template
https://store.seobytes.eu/index.php/en/headpiece/cap-baseball-detail
Issue persists.
Title: Re: Shipment method in product view display issue
Post by: Jörgen on January 09, 2018, 13:58:05 PM
I think You have a fault in Your language file, please test with English.

In my shop i see "We ship to Sweden", You only see the W, there is something wrong here.

regards

Jörgen @ Kreativ Fotografi
Title: Re: Shipment method in product view display issue
Post by: Cococoder on January 09, 2018, 14:10:36 PM
Again site is in english, using default english template and I just reset virtuemart thanks to the tool.
no other language installed
Language file not modified

If you have anything else in mind regarding testing the site in english please specify.

Debug is enabled and it shows: 2 vmdebug 1 Language, default shoplanguage (VmConfig::$jDefLang): en_gb en-GB

Also it has nothing to do with language file as the info that are displayed should be shipment method name desciption and cost which are user entered data in the shipment plugin

Country for shipment is set as available for all.

also IMPORTANT:it was working perfectly fine before the update and no modification has been made other than updating.
Title: Re: Shipment method in product view display issue
Post by: Jörgen on January 09, 2018, 14:15:29 PM
tulen ise järele

Jörgen @ Kreativ Fotografi
Title: Re: Shipment method in product view display issue
Post by: Jörgen on January 09, 2018, 14:20:04 PM
Updated from what ???

Jörgen @ Kreativ Fotografi
Title: Re: Shipment method in product view display issue
Post by: Cococoder on January 09, 2018, 14:39:39 PM
"tulen ise järele" was entered as shipment method name.
now there is only the default plugin and issue persits
Updated from Virtuemat previous version (3.2.10 if remember correctly)  to Virtuemart current version 3.2.12

it seems that in two of my installs productDisplayShipment is not fetching the right data.

Any cue on how to solve that issue or guidance for continuing further the troubleshooting?

Also same data are displayed properly in the cart, it's where it gets confusing.
Title: Re: Shipment method in product view display issue
Post by: Cococoder on January 09, 2018, 15:20:35 PM
Quote from: Jörgen on January 09, 2018, 13:58:05 PM
In my shop i see "We ship to Sweden"

Hi again Jörgen, thanks for trying to help, just one question, as stated I am expecting to see shipment method available for the product.
In shipment methods open the shipment methods you wish to display and go to Configuration and set "Show on product details page" to yes.
When you do that. The shipment method name and description and price are displayed for eligible product country etc.

Is "Show on product details page" enable for your shipment methods?
If no, then this information is not relevant to the case. Indeed "we sheep to sweden" does not match what is expected from a shipment methods name or description hence the question. It seems we are speaking of two different things here.
Thanks for your help in this matter.

After further research
So it seems on your site this string is displayed: VMSHIPMENT_WEIGHT_COUNTRIES_SHIP_TO="We ship to "
Whereas I am expecting a variable containing the name and one containing the price of the shipment method as it was before the update. Do you have this info displayed on your site correctly?


Maybe the key lies in the XML

Further TS: the shipment logo is not displayed
All info are displayed correctly in the cart view

Title: Re: Shipment method in product view display issue
Post by: Jörgen on January 09, 2018, 16:00:14 PM
Yes display on product page must be chosen.

Have you not tried this before?
After that text comes information from the shipping method.
I would reinstall without uninstalling. And maybe check the language file.
Regards
Jörgen @ Kreativ Fotografi

Title: Re: Shipment method in product view display issue
Post by: Cococoder on January 09, 2018, 16:22:06 PM
Obviously it is chosen
I am double checking with your settings to verify we are speaking about the same thing. This string "We ship to" did not appear prior to the update.
Language file is fine (I just copied the exact same string that seems to cause issue in the reply above)
also I tried to reinstall from the tools just right now and the issue persists

I did a test with payment method and it did display paypal logo
I will try a complete re-install but it is not a proper solution for the production site

Title: Re: Shipment method in product view display issue
Post by: jenkinhill on January 09, 2018, 18:35:29 PM
I just looked at the generated page code for the url above, and see:

<div class="roductDisplayShipments roductDisplayShipments-0">
                   W               </div>

That should be "productDisplayShipments productDisplayShipments"  so have you edited  productdetails/default.php ?

The "With shipment....."  content is generated in  plugins/vmshipment/weight_countries/tmpl/default.php using:

echo vmtext::sprintf('VMSHIPMENT_WEIGHT_COUNTRIES_WITH_SHIPMENT', $viewData['method']->shipment_name, $currency->priceDisplay($viewData['product']->prices['shipmentPrice']));

It is not unknown for errors to occur during installation, and reinstalling using Joomla's extentions manager usually overwrites any errors.
Title: Re: Shipment method in product view display issue
Post by: Cococoder on January 09, 2018, 21:48:28 PM
Yes I did a test by editing echo substr($productDisplayType,0, -1) to echo substr($productDisplayType,1). even without that edit, issue persists (I edited back to normal).

I'll try your suggestion and let you know the results.

Thanks for your input.
Title: Re: Shipment method in product view display issue
Post by: Cococoder on January 10, 2018, 09:45:31 AM
Hi Jenkinhill,

I uncommented and edited the vmdebug in the default.php file and verified that $viewData['method']->shipment_name and  $currency->priceDisplay($viewData['product']->prices['shipmentPrice']) from the line
echo vmtext::sprintf('VMSHIPMENT_WEIGHT_COUNTRIES_WITH_SHIPMENT', $viewData['method']->shipment_name, $currency->priceDisplay($viewData['product']->prices['shipmentPrice']));
returns the correct data.

By printing the variables I could determine that $this->$productDisplayType is only made of an array of length one, with the value being the first letter of VMSHIPMENT_WEIGHT_COUNTRIES_WITH_SHIPMENT

Uninstalling and reinstalling the shipment plugin did not solve the issue - cached was cleared.

Note: to narrow down the cause of the error, I edited default.php in weight_countries this way: echo  $viewData['method']->shipment_name.' '.$currency->priceDisplay($viewData['product']->prices['shipmentPrice']);

The result is that it is now the first letters of the shipment_name variable that is displayed.
Title: Re: Shipment method in product view display issue
Post by: Cococoder on January 10, 2018, 12:04:08 PM
Okay, keeping you guy posted about the issue.

I just di a fresh installed of joomla and a fresh install of virtuemart without any additional edit, plugin, nor template. Everything is straight out of the box.

Issue is there. It seems we have a legitimate bug here.

PHP version:    7.1.12
Joomla! Version   Joomla! 3.8.3 Stable [ Amani ] 12-December-2017 15:00 GMT
Joomla! Platform Version   Joomla Platform 13.1.0 Stable [ Curiosity ] 24-Apr-2013 00:00 GMT
VirtueMart 3.2.12
You can check here with debug mod enable
https://store.seobytes.eu/index.php/test/test-detail
Title: Re: Shipment method in product view display issue
Post by: jenkinhill on January 10, 2018, 12:32:10 PM
Can you try a different PHP version? I have seen some bug reports with PHP 7.1.12  I think most of us are still on PHP7.0.x (or earlier).

Also try creating a language override for VMSHIPMENT_WEIGHT_COUNTRIES_WITH_SHIPMENT  using  "With shipment %1s for %2s"  and if you see just the W again try changing the wording.

Title: Re: Shipment method in product view display issue
Post by: Cococoder on January 10, 2018, 14:18:55 PM
I am taking care of the php downgrade. Meanwhile can you sketch out for me how the data from
echo vmtext::sprintf('VMSHIPMENT_WEIGHT_COUNTRIES_WITH_SHIPMENT', $viewData['method']->shipment_name, $currency->priceDisplay($viewData['product']->prices['shipmentPrice']));
are assigned to $productDisplayShipments
My goal is to write a piece of code to get the shipment method info. They are correctly displayed in the debug mode therefore I should be able to call them as simply in the body of the page.

Any hint regarding how to do this would be appreciated.
Title: Re: Shipment method in product view display issue
Post by: Jörgen on January 10, 2018, 15:02:47 PM
"With shipment %1s for %2s"

%1s = Shipment name
%2s = Cost of shipment

regards

Jörgen @ Kreativ Fotografi
Title: Re: Shipment method in product view display issue
Post by: Cococoder on January 10, 2018, 15:25:44 PM
thanks Jörgen, you actually answer what is the value off $productDisplayShipments , not how/where this value is assigned.

I understand this might be trivial to a lot of you, unfortunately it is not trivial to me.

Thanks again for your input guys
Title: Re: Shipment method in product view display issue
Post by: jenkinhill on January 10, 2018, 17:42:25 PM
The files you want are:

plugins/vmshipment/weight_countries/weight_countries.php
components/com_virtuemart/views/productdetails/view.html.php
Title: Re: Shipment method in product view display issue
Post by: Jörgen on January 11, 2018, 09:15:38 AM
If You didn´t see the text "With shipment .... "  before the update You must have some overrides.
You may have an language override for the key:
"VMSHIPMENT_WEIGHT_COUNTRIES_WITH_SHIPMENT"
\plugins\vmshipment\weight_countries\language\en-GB\en-GB.plg_vmshipment_weight_countries.ini

You can also have an override in
/templates/your-template/html/vmshipment/weight_countries/default.php

There is where my text "We ship to.. " is added


regards

Jörgen @ Kreativ Fotografi
Title: Re: Shipment method in product view display issue
Post by: Cococoder on January 11, 2018, 12:39:51 PM
Hi Jörgen,

The test site I am troubleshooting now with your help is as barebone as you can get, no override here or customisation. Fresh install.

Those said, the the template I use on the production site has a product detail override but this is not the matter at hand at the moment.

If the debug mode reports correct information, there should be a way to get this working properly even on php 7.1

@jenkinhill
Thanks for the pointer, I'll try to find my way in the code.
[EDIT] Rolling back to php 7.0 solved the issue

Thanks for helping me out on that one.