Checkout page / Cart page SEF URL problems

Started by Genius WebDesign, January 21, 2015, 21:31:16 PM

Previous topic - Next topic

2cool

It's not a multi language site, all set to Dutch.
But still adds /cart (english) at cart page??

Regards,
Pascal

Genius WebDesign

Being the one that started this thread I though I should revisit and tell you all how I fixed the problem.

In the VM router file:
/components/com_virtuemart/router.php

from line 248 - i changed this:
case 'cart';
if(!isset($query['Itemid'])){
if ( isset($jmenu['cart']) ) {
$query['Itemid'] = $jmenu['cart'];
} else if ( isset($jmenu['virtuemart']) ) {
$query['Itemid'] = $jmenu['virtuemart'];
}
}
$segments[] = $helper->lang('cart') ;

break;



to this:
        case 'cart';
        if (isset($jmenu['cart'])) {
$query['Itemid'] = $jmenu['cart'];
} else if ( isset($jmenu['virtuemart']) ) {
$query['Itemid'] = $jmenu['virtuemart'];
}

$segments[] = '';

break;



And now I have a beautiful SEF URL for the cart view that adheres to the Joomla menu item set for the cart view, and the trailing "/cart" is gone :)
Hope this comes in handy for others with the same issue.

Studio 42

Hi,
i think the right solution is:


                        case 'cart';
                                if (isset($jmenu['cart'])) {
$query['Itemid'] = $jmenu['cart'];
} else if ( isset($jmenu['virtuemart']) ) {
$query['Itemid'] = $jmenu['virtuemart'];
$segments[] = $helper->lang('cart') ;
} else {
                                        // the worst
$segments[] = $helper->lang('cart') ;
}


break;

Genius WebDesign

Quotei think the right solution is

Yes indeed, your solution is better with a built in "safety net"

sandomatyas

It seems the problem is still in the latest VM (3.0.14). I checked the source and seems the links of padedd.php are prepared in prepareContinueLink function of VmView helper. As far I can tell this function doesn't  use any JRoute call.
It builds the cart link like this:
$this->cart_link = $scheme.'://'.$juri. JURI::root(true).'/index.php?option=com_virtuemart&view=cart'.$lang;
If I check the source anywere else, the cart link is prepared like this:
JRoute::_('index.php?option=com_virtuemart&view=cart');
Is there maybe some reason for that?

Studio 42

Quote from: sandomatyas on March 16, 2016, 07:26:21 AM
It seems the problem is still in the latest VM (3.0.14). I checked the source and seems the links of padedd.php are prepared in prepareContinueLink function of VmView helper. As far I can tell this function doesn't  use any JRoute call.
It builds the cart link like this:
$this->cart_link = $scheme.'://'.$juri. JURI::root(true).'/index.php?option=com_virtuemart&view=cart'.$lang;
If I check the source anywere else, the cart link is prepared like this:
JRoute::_('index.php?option=com_virtuemart&view=cart');
Is there maybe some reason for that?
This was to Fix some problem for some user.
But old version was not a problem at the moment the menu was set corretly and new version have another problem now.
The Joomla menu itemID is not set and you cannot modifiy the cart render now !
So menu , modules ... are same as in HOME page


Studio 42

WHat i do, is overide of YOURSITE/components/com_virtuemart/views/cart/tmpl/padded.php
And i add after
defined('_JEXEC') or die('Restricted access');
this line
$this->cart_link = jroute::_('index.php?option=com_virtuemart&view=cart');
This permit to not hack the core and solve the problem for itemId missing.
Note: if itemId is in a menu only visible from registred user, this is not working !

chehonte

component/com_virtuemart/helpers/vmvew.php

in line 132 and 142

replace with:

line 132) $this->continue_link = JRoute::_ ('index.php?option=com_virtuemart&view=category' . $categoryStr.$ItemidStr, FALSE);
line 142) $this->cart_link = JRoute::_('index.php?option=com_virtuemart&view=cart'.$ItemidStr, FALSE);

Studio 42

Quote from: chehonte on October 27, 2016, 10:33:07 AM
component/com_virtuemart/helpers/vmvew.php

in line 132 and 142

replace with:

line 132) $this->continue_link = JRoute::_ ('index.php?option=com_virtuemart&view=category' . $categoryStr.$ItemidStr, FALSE);
line 142) $this->cart_link = JRoute::_('index.php?option=com_virtuemart&view=cart'.$ItemidStr, FALSE);
THe idea is not bad, but it's better to overide in template this in component/com_virtuemart/views/cart/tmpl/padded.php as i explained in another post

Milbo

The problem are the different methods to setup a joomla menu, in special when there are different languages used.

For example, the most laziest setup is a menu for "all languages" and then extra menues for any language. There you need to setup only the homepage menu item. Any other menu items use then the fallback from the "all language" menu. So in case you have 2 language, you get 3 menues. Others just create 2 complete menus.

and a lot people do not setup any menu item to the cart, because they only show the cart module. So when the menu setup is correct, we can show sefed links, else it creates nonsense. An hidden config is maybe the right solution.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Milbo

What about this?

if(VmConfig::get('sef_for_cart_links', false)){
$this->continue_link = JRoute::_('index.php?option=com_virtuemart&view=category' . $categoryStr.$ItemidStr);
$this->cart_link = JRoute::_('index.php?option=com_virtuemart&view=cart');
} else {
$lang = '';
if(VmConfig::$jLangCount>1 and !empty(VmConfig::$vmlangSef)){
$lang = '&lang='.VmConfig::$vmlangSef;
}

$this->continue_link = JURI::root() .'index.php?option=com_virtuemart&view=category' . $categoryStr.$lang.$ItemidStr;

$juri = JUri::getInstance();
$uri = $juri->toString(array( 'host', 'port'));

$scheme = $juri->toString(array( 'scheme'));
$scheme = substr($scheme,0,-3);
if($scheme!='https' and VmConfig::get('useSSL',false)){
$scheme .='s';
}
$this->cart_link = $scheme.'://'.$uri. JURI::root(true).'/index.php?option=com_virtuemart&view=cart'.$lang;
}

$this->continue_link_html = '<a class="continue_link" href="' . $this->continue_link . '">' . vmText::_ ('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Studio 42

Quote from: Milbo on November 02, 2016, 08:28:59 AM
The problem are the different methods to setup a joomla menu, in special when there are different languages used.

For example, the most laziest setup is a menu for "all languages" and then extra menues for any language. There you need to setup only the homepage menu item. Any other menu items use then the fallback from the "all language" menu. So in case you have 2 language, you get 3 menues. Others just create 2 complete menus.

and a lot people do not setup any menu item to the cart, because they only show the cart module. So when the menu setup is correct, we can show sefed links, else it creates nonsense. An hidden config is maybe the right solution.

I use a simple solution for this case.
Add a new menu
name it "hidden links" for eg.
Add all item menu links, cart, category, shop or what ever that has no direct links to it and all is work.
Simply do not add any modules for this menu, so you get sef links but never see the links in you website.

Milbo

#43
I dont like the idea to tell customers how they should build menus. :-) I implemented the version above, at least there is now an hidden config and anyone in this thread can just set the hidden config to have your solution. http://dev.virtuemart.net/attachments/download/1025/com_virtuemart.3.0.18.1_extract_first.zip [reupped]

the version is "stable", we use it on our store, but of course, use always a backup
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Studio 42

I don't like my solution, but this is needed for any page to have right sef. For Joomla articles or categories or other component, this is the only core solution.
SO this is the generic way to do for Joomla and work always(or perhaps not in Vm in some case).