0

I'm having a problem with my Joomla 3 mijoshop cart not emptying after purchases when SEF is enabled, if I turn SEF off then it works fine. After some searching around I believe it could be a problem with the carts router.php file, so I was wondering if anyone could help me out with this. I have pasted my current router.php files code below.

defined('_JEXEC') or die ('Restricted access');

require_once(JPATH_ROOT . '/components/com_mijoshop/mijoshop/mijoshop.php');

if (!class_exists('MiwisoftComponentRouterBase')) {
if (class_exists('JComponentRouterBase')) {
    abstract class MiwisoftComponentRouterBase extends JComponentRouterBase {}
}
else {
    class MiwisoftComponentRouterBase {}
}
}

class MijoShopRouter extends MiwisoftComponentRouterBase
{

static $cats = array();
static $path = array();

public function build(&$query) {
    return $this->buildRoute($query);
}

public function parse(&$segments) {
    return $this->parseRoute($segments);
}

public function buildRoute(&$query)
{
    $Itemid = null;
    $segments = array();

    $menu = $this->getMenu();

    $_get_itemid = 0;
    if($menu->getActive()){
        $_get_itemid = $menu->getActive()->id;
    }
    $_get_route = JRequest::getVar('route', '');

    if( isset($query['Itemid']) and $_get_itemid != $query['Itemid'] and $_get_route == 'product/category' and isset($query['route']) and $query['route'] == 'product/product' ){
        $query['Itemid'] = $_get_itemid;
    }

    if (!empty($query['Itemid'])) {
        $Itemid = $query['Itemid'];
    } else {
        $Itemid = $this->getItemid();
    }

    if (empty($Itemid)) {
        $a_menu = $menu->getActive();
    } else {
        $a_menu = $menu->getItem($Itemid);
    }

    if (isset($query['view'])) {
        if ($query['view'] == 'admin') {
            unset($query['view']);

            return $segments;
        }
        $_route = $this->getRoute($query['view'], false);
        if (!empty($_route)) {
            $query['route'] = $_route;
            unset($query['view']);
        }
        else {
            $segments[] = $query['view'];
            unset($query['view']);
        }
    }

    if (isset($query['route'])) {
        switch ($query['route']) {
            case 'product/product':
                if (is_object($a_menu) and $a_menu->query['view'] == 'product' and $a_menu->query['product_id'] == @$query['product_id']) {
                    unset($query['path']);
                    unset($query['product_id']);
                    unset($query['manufacturer_id']);
                    break;
                }

                $segments[] = 'product';

                if (isset($query['product_id'])) {
                    $id = $query['product_id'];
                    $name = MijoShop::get('db')->getRecordAlias($id);

                    if (!empty($name)) {
                        $segments[] = $id . ':' . $name;
                    } else {
                        $segments[] = $id;
                    }

                    unset($query['path']);
                    unset($query['product_id']);
                    unset($query['manufacturer_id']);
                    unset($query['sort']);
                    unset($query['order']);
                    unset($query['filter_name']);
                    unset($query['filter_tag']);
                    unset($query['limit']);
                    unset($query['page']);

                }

                break;
            case 'product/category':
                $_path = explode('_', @$query['path']);
                $m_id = end($_path);

                if (is_object($a_menu) and $a_menu->query['view'] == 'category' and $a_menu->query['path'] == $m_id) {
                    unset($query['path']);
                    break;
                }

                $segments[] = 'category';

                if (isset($query['path'])) {
                    $id = $query['path'];

                    if (strpos($id, '_')) {
                        $old_id = $id;
                        $_id = explode('_', $id);
                        $id = end($_id);

                        self::$cats[$id] = $old_id;
                    } else {
                        self::$cats[$id] = $id;
                    }

                    $name = MijoShop::get('db')->getRecordAlias($id, 'category');

                    if (!empty($name)) {
                        $segments[] = $id . ':' . $name;
                    } else {
                        $segments[] = $id;
                    }

                    unset($query['path']);
                }

                break;
            case 'product/manufacturer/info':
                if (is_object($a_menu) and $a_menu->query['view'] == 'manufacturer' and $a_menu->query['manufacturer_id'] == @$query['manufacturer_id']) {
                    unset($query['manufacturer_id']);
                    break;
                }

                $segments[] = 'manufacturer';

                if (isset($query['manufacturer_id'])) {
                    $id = $query['manufacturer_id'];
                    $name = MijoShop::get('db')->getRecordAlias($id, 'manufacturer');

                    if (!empty($name)) {
                        $segments[] = $id . ':' . $name;
                    } else {
                        $segments[] = $id;
                    }

                    unset($query['manufacturer_id']);
                }

                break;
            case 'information/information':
                if (is_object($a_menu) and $a_menu->query['view'] == 'information' and $a_menu->query['information_id'] == @$query['information_id']) {
                    unset($query['information_id']);
                    break;
                }

                $segments[] = 'information';

                if (isset($query['information_id'])) {
                    $id = $query['information_id'];
                    $name = MijoShop::get('db')->getRecordAlias($id, 'information');

                    if (!empty($name)) {
                        $segments[] = $id . ':' . $name;
                    } else {
                        $segments[] = $id;
                    }

                    unset($query['information_id']);
                }

Thanks in advance to anyone that can help :)

  • Mijoshop is a commercial extension, therefore you should be contacting the developer – Lodder Jun 27 '14 at 23:48
  • I have already contacted the mijoshop support team, but their support doesn't seem great. They closed my ticket without a solution and it's been over a week now with no signs of any fix so I thought I would look elsewhere. Thanks anyway – user3782724 Jun 29 '14 at 12:44
  • Wow, that actually **is** bad. – Lodder Jun 29 '14 at 13:37

1 Answers1

0

The problem has nothing to do with your router.php file, it has to do with the checkout process since those cart items are actually stored in the database.

When you add items to your cart, they are added to a table in the database, once you checkout, your items are usually added to an order_item table, and order table is populated with your order information, and the cart is emptied.

I would check the controller/model files to see where the checkout code is - the bug is definitely there.

itoctopus
  • 4,133
  • 4
  • 32
  • 44