Author Topic: Checkout page / Cart page SEF URL problems  (Read 51858 times)

2cool

  • Jr. Member
  • **
  • Posts: 295
Re: Checkout page / Cart page SEF URL problems
« Reply #30 on: July 06, 2015, 17:35:33 pm »
It's not a multi language site, all set to Dutch.
But still adds /cart (english) at cart page??

Regards,
Pascal

Genius WebDesign

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 175
    • Genius WebDesign
Re: Checkout page / Cart page SEF URL problems
« Reply #31 on: July 24, 2015, 00:11:57 am »
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:
Code: [Select]
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:
Code: [Select]
        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

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4679
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Checkout page / Cart page SEF URL problems
« Reply #32 on: July 24, 2015, 01:02:25 am »
Hi,
i think the right solution is:

Code: [Select]
                        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

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 175
    • Genius WebDesign
Re: Checkout page / Cart page SEF URL problems
« Reply #33 on: July 24, 2015, 13:17:47 pm »
Quote
i think the right solution is

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

sandomatyas

  • Jr. Member
  • **
  • Posts: 384
Re: Checkout page / Cart page SEF URL problems
« Reply #34 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:
Code: [Select]
$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:
Code: [Select]
JRoute::_('index.php?option=com_virtuemart&view=cart');Is there maybe some reason for that?

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4679
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Checkout page / Cart page SEF URL problems
« Reply #35 on: March 16, 2016, 11:24:18 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:
Code: [Select]
$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:
Code: [Select]
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

Ghost

  • Jr. Member
  • **
  • Posts: 423

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4679
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Checkout page / Cart page SEF URL problems
« Reply #37 on: March 16, 2016, 18:15:34 pm »
WHat i do, is overide of YOURSITE/components/com_virtuemart/views/cart/tmpl/padded.php
And i add after
Code: [Select]
defined('_JEXEC') or die('Restricted access');this line
Code: [Select]
$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

  • Beginner
  • *
  • Posts: 1
  • A beginner
Re: Checkout page / Cart page SEF URL problems
« Reply #38 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);

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4679
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Checkout page / Cart page SEF URL problems
« Reply #39 on: October 27, 2016, 11:37:21 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

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10544
  • VM4.0.7 Eagle Owl
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Checkout page / Cart page SEF URL problems
« Reply #40 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.
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

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10544
  • VM4.0.7 Eagle Owl
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Checkout page / Cart page SEF URL problems
« Reply #41 on: November 02, 2016, 08:33:47 am »
What about this?
Code: [Select]
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

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4679
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Checkout page / Cart page SEF URL problems
« Reply #42 on: November 02, 2016, 16:48:53 pm »
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

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 10544
  • VM4.0.7 Eagle Owl
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Checkout page / Cart page SEF URL problems
« Reply #43 on: November 04, 2016, 19:46:58 pm »
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

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4679
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Checkout page / Cart page SEF URL problems
« Reply #44 on: November 04, 2016, 22:41:02 pm »
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).