We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 41428
    • 22 Posts
    Hi

    I'm using minishop2 2.1.3-pl2, on Revo 2.2.10-pl and have a multi-context site using Babel 2.2.5: one for England (web), and one for USA (us).

    I'd like to restrict the "cart items" to each context - so when user is visiting the UK site and adds a product from the UK shop into their basket, if they click on the "switch to US site" Babel link their cart is now empty. The reason being the UK prices are in GBP and in USD for the relevant context.

    I've tried setting system variables:

    session_cookie_domain
    session_cookie_path

    for each of the context settings in hope that the session cookie stores the cart info, so when the context is changed a new session is started, but this hasn't worked...

    Any Ideas?
      • 41428
      • 22 Posts
      Think I've solved it...

      Make a new cart handler and edit a snippet:

      --- EDIT 1 ---
      FILE mscarthandler.class.php
      LINE 179
      ADD
      ,'ctx' => $this->modx->context->get('key')
      REASON: adds users current context into array key for current item
      
      --- EDIT 2 ---
      FILE mscarthandler.class.php
      LINES 258-260
      EDIT
      if($item['ctx'] == $this->modx->context->get('key')){
      	$status['total_count'] += $item['count'];
      	$status['total_cost'] += $item['price'] * $item['count'];
      	$status['total_weight'] += $item['weight'] * $item['count'];
      }
      REASON: selects only items added from that context
      
      --- EDIT 3 ---
      FILE msCart Snippet
      LINE 70
      EDIT
      //is not empty and relevant to the context, then show
      if (!empty($rows[0]) && $v['ctx'] == $modx->context->key) {
      REASON: selects only items added from that context