0

在启用 SEF 时,我的 Joomla 3 mijoshop 购物车在购买后没有清空时遇到问题,如果我关闭 SEF,那么它工作正常。经过一番搜索,我相信这可能是 carts router.php 文件的问题,所以我想知道是否有人可以帮助我解决这个问题。我在下面粘贴了我当前的 router.php 文件代码。

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']);
                }

提前感谢任何可以提供帮助的人:)

4

1 回答 1

0

该问题与您的 router.php 文件无关,它与结帐过程有关,因为这些购物车项目实际上存储在数据库中。

当您将商品添加到购物车时,它们会添加到数据库中的表中,一旦您结帐,您的商品通常会添加到 order_item 表中,并且订单表中会填充您的订单信息,并且购物车会被清空。

我会检查控制器/模型文件以查看签出代码的位置 - 错误肯定存在。

于 2014-06-30T17:23:37.860 回答