News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Add to cart issue when menu set to Category layout – no itemid in url?

Started by johk, February 11, 2013, 12:34:19 PM

Previous topic - Next topic

johk

Hi,
Using VM 2.0.18(a) and Joomla 2.5.8
SEO is disabled

The menu item to VirtueMart » Category Layout. The layout of the products is OK and I have assigned a module to suite.
Clicking on products details brings up the detail page of the products. On the detail page I click add to cart which brings up the modal pop-up window.
If I click 'Continue Shopping' I am brought back to the shop but my modules assigned are gone. I believe it has to do with that "itemid" is not present in the URL.

Are there any fix for this? I have seen this http://forum.virtuemart.net/index.php?topic=108000.msg379354#msg379354 which is a temporary solution but what happens when I update VM?

Thanks,

johk

sandstorm

There is a similar problem when using SH404 SEF. That link does not work when SH404 is on.

I asked for help on SH404 support forum and they say the link does not render with item id & needs to be fixed by VM.

This is a big problem for SEF & like johnK reports for showing modules correctly when using the link.

Can this be added to a fix list, or is it already in future versions of VM2?
J3.6.4 / PHP7.0.12
VM3.0.16

jenkinhill

Itemids are present in the urls of my 2.0.20a test sites in cat view.
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

This is a related issue with missing Itemids but in the cart module.

I have solved the missing Itemid on the cart popup with alanski's post here : http://forum.virtuemart.net/index.php?topic=108000.0



I'm building a 4 language site

As I understand it:
1. make a menu to to index.php?option=com_virtuemart&view=virtuemart as an all language/main menu
tried multiple (each language) vm root menu but VM coughed big time on this...
2. make a per language Cart menu (hidden in my case) and link them in the Association dialog to each other

Publish the modules you want by language etc to each of the Cart menus..


If you use the Cart module it just takes what ever Itemid that you happen to be on - which is plainly wrong... there are no paricular modules configured language wise for many possible Itemids or worse no Itemid is passed.
below forces the Itemid for the particular Cart language menu

file modules/mod_virtuemart_cart/mod_virtuemart_cart.php ~ line 49 add (use the nesscesary lang var and Itemid of your cart menus)


$lang2 = JRequest::getVar('lang');
switch ($lang2)
{
case 'fr':
  $itemid= '205';
  break;
case 'de':
  $itemid= '204';
  break;
case 'it':
  $itemid= '206';
  break;
default:
  $itemid= '202';
}


then change

$data->cart_show = '<a style ="float:right;" href="'.JRoute::_("index.php?option=com_virtuemart&view=cart".$taskRoute,$useXHTML,$useSSL).'">'.$linkName.'</a>';

to

$data->cart_show = '<a style ="float:right;" href="'.JRoute::_("index.php?option=com_virtuemart&view=cart&Itemid=".$itemid.$taskRoute,$useXHTML,$useSSL).'">'.$linkName.'</a>';

then you get proper urls like

index.php?option=com_virtuemart&view=cart&Itemid=205&lang=fr
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

An up date  -

QuoteI have solved the missing Itemid on the cart popup with alanski's post here : http://forum.virtuemart.net/index.php?topic=108000.0

this didn't actually work with a multi-lingual shop ..  :-\

this did - if it helps anyone
same file and function as above..

public function addJS() {

      //maybe we should use $mainframe->close(); or jexit();instead of die;
      /* Load the cart helper */
      //require_once(JPATH_VM_SITE.DS.'helpers'.DS.'cart.php');
      $this->json = null;
      //added by joomkit
      $menuid = JRequest::getVar('Itemid');
//added by GJC  
  $lang2 = JRequest::getVar('lang');
switch ($lang2)
{
case 'fr':
  $itemid= '205';
  break;
case 'de':
  $itemid= '204';
  break;
case 'it':
  $itemid= '206';
  break;
default:
  $itemid= '202';
}
//added by GJC
      $cart = VirtueMartCart::getCart(false);
      if ($cart) {
         // Get a continue link */
         $virtuemart_category_id = shopFunctionsF::getLastVisitedCategoryId();
         if ($virtuemart_category_id) {
            $categoryLink = '&view=category&virtuemart_category_id=' . $virtuemart_category_id.'&Itemid='.$itemid; //amended by gjc

         } else
         $categoryLink = '';
         $continue_link = JRoute::_('index.php?option=com_virtuemart' . $categoryLink.'&Itemid='.$menuid);
         $virtuemart_product_ids = JRequest::getVar('virtuemart_product_id', array(), 'default', 'array');
         $errorMsg = JText::_('COM_VIRTUEMART_CART_PRODUCT_ADDED');
         if ($cart->add($virtuemart_product_ids, $errorMsg )) {

            $this->json->msg = '<a class="continue" href="' . $continue_link . '" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
            $this->json->msg .= '<a class="showcart floatright" href="' . JRoute::_("index.php?option=com_virtuemart&view=cart&Itemid=".$itemid) . '">' . JText::_('COM_VIRTUEMART_CART_SHOW_MODAL') . '</a>'; //amended by gjc
            if ($errorMsg) $this->json->msg .= '<div>'.$errorMsg.'</div>';
            $this->json->stat = '1';
         } else {
            // $this->json->msg = '<p>' . $cart->getError() . '</p>';
            $this->json->msg = '<a class="continue" href="' . $continue_link . '" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
            $this->json->msg .= '<div>'.$errorMsg.'</div>';
            $this->json->stat = '2';
         }
      } else {
         $this->json->msg = '<a href="' . JRoute::_('index.php?option=com_virtuemart') . '" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
         $this->json->msg .= '<p>' . JText::_('COM_VIRTUEMART_MINICART_ERROR') . '</p>';
         $this->json->stat = '0';
      }
      echo json_encode($this->json);
      jExit();
   }

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


herr.proof

Quote from: GJC Web Design on March 21, 2013, 19:13:04 PM
...
this didn't actually work with a multi-lingual shop ..  :-\

this did - if it helps anyone

It saves my day by half (the other part of my problem with multi-lingual shops is a strange 'amp;' garbling destination urls in a few buttons, but I have a thread for this  :-)  )
Thank you and cheers!!

** Edit of 2013, Mar 25 **
Would you kindly expand the subject in "forgot your username" and "forgot your password" links,  too? Thank you in advance!!
note: the 'amp;' error disappears setting  'ON'  <URL SEF>in Global Configuration...

GJC Web Design

Basically the same idea in components/com_virtuemart/views/user/tmpl/login.php  around lines 150
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

sandstorm

Quote from: jenkinhill on March 17, 2013, 13:49:14 PM
Itemids are present in the urls of my 2.0.20a test sites in cat view.
I just upgraded from 2.0.18 to 2.0.20b the fix that I applied from here http://forum.virtuemart.net/index.php?topic=108000.0
has been overwritten, and it still doesn't work.

No item ID on continue shopping and other areas of VM2.

I can apply the fix again, but would be nice if the VM devs could just add this into future releases.
J3.6.4 / PHP7.0.12
VM3.0.16

herr.proof

Unsure if this is the right thing to do,
but instead of starting another thread,
I'm adding this plea of mine here...
So,
I am back :-)

But another issue put out its ugly head...   :o

Whatever search module type I use, it loses the itemid...   :'(

Do you think it to be of help the hack we told before about cart php ?
And if yes, what file would be interested by this new hack ?

Thank you for any help !!   :)

Milbo

Do you have sef activated? yes or no?

The method to find the correct item id is ony implemented if you have sef enabled, yes, then you cant see the itemid, but it is there.
Again it does NOT work with sef DISABLED. But it does work with SEF ENABLED. Please consider!
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

herr.proof

Quote from: Milbo on May 25, 2013, 16:21:29 PM
Do you have sef activated? yes or no?

The method to find the correct item id is ony implemented if you have sef enabled, yes, then you cant see the itemid, but it is there.
Again it does NOT work with sef DISABLED. But it does work with SEF ENABLED. Please consider!

I enabled and disabled it, mixed with and without the option 'rewrite SEF URL'.
The French search gives results in French language, as the English one in English language, etc... but all of them builds links that open pages "in the correct language" BUT within the 'all' ambient (mainmenu-all).  ???

Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

guybr

Quote from: GJC Web Design on March 21, 2013, 19:13:04 PM
An up date  -

QuoteI have solved the missing Itemid on the cart popup with alanski's post here : http://forum.virtuemart.net/index.php?topic=108000.0

this didn't actually work with a multi-lingual shop ..  :-\

this did - if it helps anyone
same file and function as above..

public function addJS() {

      //maybe we should use $mainframe->close(); or jexit();instead of die;
      /* Load the cart helper */
      //require_once(JPATH_VM_SITE.DS.'helpers'.DS.'cart.php');
      $this->json = null;
      //added by joomkit
      $menuid = JRequest::getVar('Itemid');
//added by GJC  
  $lang2 = JRequest::getVar('lang');
switch ($lang2)
{
case 'fr':
  $itemid= '205';
  break;
case 'de':
  $itemid= '204';
  break;
case 'it':
  $itemid= '206';
  break;
default:
  $itemid= '202';
}
//added by GJC
      $cart = VirtueMartCart::getCart(false);
      if ($cart) {
         // Get a continue link */
         $virtuemart_category_id = shopFunctionsF::getLastVisitedCategoryId();
         if ($virtuemart_category_id) {
            $categoryLink = '&view=category&virtuemart_category_id=' . $virtuemart_category_id.'&Itemid='.$itemid; //amended by gjc

         } else
         $categoryLink = '';
         $continue_link = JRoute::_('index.php?option=com_virtuemart' . $categoryLink.'&Itemid='.$menuid);
         $virtuemart_product_ids = JRequest::getVar('virtuemart_product_id', array(), 'default', 'array');
         $errorMsg = JText::_('COM_VIRTUEMART_CART_PRODUCT_ADDED');
         if ($cart->add($virtuemart_product_ids, $errorMsg )) {

            $this->json->msg = '<a class="continue" href="' . $continue_link . '" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
            $this->json->msg .= '<a class="showcart floatright" href="' . JRoute::_("index.php?option=com_virtuemart&view=cart&Itemid=".$itemid) . '">' . JText::_('COM_VIRTUEMART_CART_SHOW_MODAL') . '</a>'; //amended by gjc
            if ($errorMsg) $this->json->msg .= '<div>'.$errorMsg.'</div>';
            $this->json->stat = '1';
         } else {
            // $this->json->msg = '<p>' . $cart->getError() . '</p>';
            $this->json->msg = '<a class="continue" href="' . $continue_link . '" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
            $this->json->msg .= '<div>'.$errorMsg.'</div>';
            $this->json->stat = '2';
         }
      } else {
         $this->json->msg = '<a href="' . JRoute::_('index.php?option=com_virtuemart') . '" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
         $this->json->msg .= '<p>' . JText::_('COM_VIRTUEMART_MINICART_ERROR') . '</p>';
         $this->json->stat = '0';
      }
      echo json_encode($this->json);
      jExit();
   }



I did this, but it made no difference: I created 4 menus, each one referencing the Cart in a different language, and I referenced the menu item ID as the item IDs below; the language codes I pulled from the "Language Manager" tags. I'm using VM 2.6.6 and I'm having the same "itemid" problem on a multilingual site. I had to turn SEF off because it was causing problems.

Can someone point me in the right direction? here's what my file looks like with the patch from above. The line require_once(JPATH_VM_SITE.DS.'helpers'.DS.'cart.php'); was originally commened out (as per above); I also tried it without the comment-out:

$jsVars  = ' jQuery(document).ready(function(){
   jQuery(".vmCartModule").productUpdate();

});' ;

if (!class_exists( 'VmConfig' )) require(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart'.DS.'helpers'.DS.'config.php');

VmConfig::loadConfig();
VmConfig::loadJLang('com_virtuemart', true);
VmConfig::loadModJLang('mod_virtuemart_cart', true);

//This is strange we have the whole thing again in controllers/cart.php public function viewJS()
if(!class_exists('VirtueMartCart')) require(JPATH_VM_SITE.DS.'helpers'.DS.'cart.php');
$cart = VirtueMartCart::getCart(false);

$viewName = JRequest::getString('view',0);
if($viewName=='cart'){
   $checkAutomaticPS = true;
} else {
   $checkAutomaticPS = false;
}
$data = $cart->prepareAjaxData($checkAutomaticPS);
if (!class_exists('CurrencyDisplay')) require(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'currencydisplay.php');
$currencyDisplay = CurrencyDisplay::getInstance( );
$lang = JFactory::getLanguage();
$extension = 'com_virtuemart';
$lang->load($extension);//  when AJAX it needs to be loaded manually here >> in case you are outside virtuemart !!!
   public function addJS() {
      //maybe we should use $mainframe->close(); or jexit();instead of die;
      /* Load the cart helper */
      require_once(JPATH_VM_SITE.DS.'helpers'.DS.'cart.php');
      $this->json = null;
      //added by joomkit
      $menuid = JRequest::getVar('Itemid');
//added by GJC    
     $lang2 = JRequest::getVar('lang');
switch ($lang2)
{
case 'en-GB':
  $itemid= '1009';
  break;
case 'de-DE':
  $itemid= '1010';
  break;
case 'he-IL':
  $itemid= '1012';
  break;
default:
  $itemid= '1011';
}
//added by GJC   
      $cart = VirtueMartCart::getCart(false);
      if ($cart) {
         // Get a continue link */
         $virtuemart_category_id = shopFunctionsF::getLastVisitedCategoryId();
         if ($virtuemart_category_id) {
            $categoryLink = '&view=category&virtuemart_category_id=' . $virtuemart_category_id.'&Itemid='.$itemid; //amended by gjc
         } else
         $categoryLink = '';
         $continue_link = JRoute::_('index.php?option=com_virtuemart' . $categoryLink.'&Itemid='.$menuid);
         $virtuemart_product_ids = JRequest::getVar('virtuemart_product_id', array(), 'default', 'array');
         $errorMsg = JText::_('COM_VIRTUEMART_CART_PRODUCT_ADDED');
         if ($cart->add($virtuemart_product_ids, $errorMsg )) {
            $this->json->msg = '<a class="continue" href="' . $continue_link . '" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
            $this->json->msg .= '<a class="showcart floatright" href="' . JRoute::_("index.php?option=com_virtuemart&view=cart&Itemid=".$itemid) . '">' . JText::_('COM_VIRTUEMART_CART_SHOW_MODAL') . '</a>'; //amended by gjc
            if ($errorMsg) $this->json->msg .= '<div>'.$errorMsg.'</div>';
            $this->json->stat = '1';
         } else {
            // $this->json->msg = '<p>' . $cart->getError() . '</p>';
            $this->json->msg = '<a class="continue" href="' . $continue_link . '" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
            $this->json->msg .= '<div>'.$errorMsg.'</div>';
            $this->json->stat = '2';
         }
      } else {
         $this->json->msg = '<a href="' . JRoute::_('index.php?option=com_virtuemart') . '" >' . JText::_('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
         $this->json->msg .= '<p>' . JText::_('COM_VIRTUEMART_MINICART_ERROR') . '</p>';
         $this->json->stat = '0';
      }
      echo json_encode($this->json);
      jExit();
   }
if ($data->totalProduct>1) $data->totalProductTxt = JText::sprintf('COM_VIRTUEMART_CART_X_PRODUCTS', $data->totalProduct);
else if ($data->totalProduct == 1) $data->totalProductTxt = JText::_('COM_VIRTUEMART_CART_ONE_PRODUCT');
else $data->totalProductTxt = JText::_('COM_VIRTUEMART_EMPTY_CART');
if (false && $data->dataValidated == true) {
   $taskRoute = '&task=confirm';
   $linkName = JText::_('COM_VIRTUEMART_ORDER_CONFIRM_MNU');
} else {
   $taskRoute = '';
   $linkName = JText::_('COM_VIRTUEMART_CART_SHOW');
}
$useSSL = VmConfig::get('useSSL',0);
$useXHTML = true;
$data->cart_show = '<a style ="float:right;" href="'.JRoute::_("index.php?option=com_virtuemart&view=cart".$taskRoute,$useXHTML,$useSSL).'">'.$linkName.'</a>';
$data->billTotal = $lang->_('COM_VIRTUEMART_CART_TOTAL').' : <strong>'. $data->billTotal .'</strong>';

//vmJsApi::jPrice();
vmJsApi::cssSite();
$document = JFactory::getDocument();
//$document->addScriptDeclaration($jsVars);
$moduleclass_sfx = $params->get('moduleclass_sfx', '');
$show_price = (bool)$params->get( 'show_price', 1 ); // Display the Product Price?
$show_product_list = (bool)$params->get( 'show_product_list', 1 ); // Display the Product Price?
/* Laod tmpl default */
require(JModuleHelper::getLayoutPath('mod_virtuemart_cart'));
?>