Помощь ocStore 1.5 Shoputils.CumulativeDiscounts 1.1

dimon7772

Профессор
Регистрация
30 Апр 2013
Сообщения
170
Реакции
41
Появилась задача вывести в личном кабинете общую сумму покупок и текущий процент скидки.
Как я понимаю, нужно вытащить из модуля (shoputils_cumulative_discounts_.tpl) переменные и вставить в шаблон account.tpl
PHP:
<?php echo $text_customer; ?><br/><br/>
            <?php if (isset($text_cumulative_summ)) { ?>
                <?php echo $text_cumulative_summ; ?><br/><br/>
            <?php } ?>
            <?php echo $text_description; ?><br/><br/>
            <a href="<?php echo $href_discounts; ?>"><?php echo $text_href_discounts; ?></a>
Но выдаёт ошибки, как понимаю, надо из контролёра модуля скопировать какой-то кусок кода.
PHP:
class ControllerModuleShoputilscumulativediscounts extends Controller {

    public function discounts() {
        $this->load->model('total/shoputils_cumulative_discounts');
        $this->language->load('module/shoputils_cumulative_discounts_');

        $this->data['breadcrumbs'] = array();

        $this->document->setTitle($this->language->get('heading_full_title'));
        $this->data['heading_title'] = $this->language->get('heading_full_title');

         $this->data['breadcrumbs'][] = array(
            'href'      => HTTP_SERVER . 'index.php?route=common/home',
            'text'      => $this->language->get('text_home'),
            'separator' => $this->language->get('text_separator')
        );

         $this->data['breadcrumbs'][] = array(
           'href'      => HTTP_SERVER . 'index.php?route=module/shoputils_cumulative_discounts_/discounts',
           'text'      => $this->language->get('heading_title'),
           'separator' => FALSE
        );


        $cmsdata = $this->data['discounts'] = $this->model_total_shoputils_cumulative_discounts->getDiscountsCMSData(
            (int)$this->config->get('config_language_id')
        );

        $this->data['description_before'] = htmlspecialchars_decode($cmsdata['description_before']);
        $this->data['description_after'] = htmlspecialchars_decode($cmsdata['description_after']);

        $this->data['discounts'] =$this->model_total_shoputils_cumulative_discounts->getDiscounts(
            (int)$this->config->get('config_store_id'),
            (int)$this->config->get('config_customer_group_id'),
            (int)$this->config->get('config_language_id')
        );

        if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/shoputils_cumulative_discounts_list.tpl')) {
            $this->template = $this->config->get('config_template') . '/template/module/shoputils_cumulative_discounts_list.tpl';
        } else {
            $this->template = 'default/template/module/shoputils_cumulative_discounts_list.tpl';
        }

        $this->children = array(
            'common/header',
            'common/footer',
            'common/column_left',
            'common/column_right'
        );

        $this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));
    }

    protected function index() {
        $this->id = 'shoputils_cumulative_discounts_';

        if ($this->customer->isLogged()){
            $this->load->model('total/shoputils_cumulative_discounts');
            $this->language->load('module/shoputils_cumulative_discounts_');
            $this->data['heading_title'] = $this->language->get('heading_title');
            $this->data['text_customer'] = $this->customer->getFirstname() . ' ' . $this->customer->getLastname();
            $this->data['href_discounts'] = HTTP_SERVER.'index.php?route=module/shoputils_cumulative_discounts_/discounts';

            if ($discount = $this->model_total_shoputils_cumulative_discounts->getLoggedCustomerDiscount() ){
                if ($discount['description']){
                    $this->data['text_description'] = $discount['description'];
                } else {
                    $this->data['text_description'] =  $this->language->get('text_description_empty');
                }
                $this->data['text_href_discounts'] = $this->language->get('text_href_discounts_logged');
                $this->data['text_cumulative_summ'] = sprintf($this->language->get('text_cumulative_summ'), $this->currency->format($discount['cumulative_summ']));
            } else {
                $this->data['text_description'] = $this->language->get('text_description_none');;
                $this->data['text_href_discounts'] = $this->language->get('text_href_discounts_not_logged');
            }

            if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/shoputils_cumulative_discounts_.tpl')) {
                $this->template = $this->config->get('config_template') . '/template/module/shoputils_cumulative_discounts_.tpl';
            } else {
                $this->template = 'default/template/module/shoputils_cumulative_discounts_.tpl';
            }

            $this->render();
        }
    }
}


?>

Вопрос №1. Какой участок брать?
Вопрос №2. Этот кусок надо вставить в account.php?
Кто может подсказать?
 
Последнее редактирование:
Удалось выполнить задуманное? Такие же мысли есть
 
Удалось выполнить задуманное? Такие же мысли есть

Все сделал.
1. В файл сайт.ru/catalog/view/theme/вашатема/template/accountaccount.tpl добавить:
<h2><span><?php echo $heading_title; ?></span></h2>
Здравствуйте <?php echo $text_customer; ?><br/>
<?php if (isset($text_cumulative_summ)) { ?>
<?php echo $text_cumulative_summ; ?><br/>
<?php } ?>
Текущие условия скидки: <?php echo $text_description; ?>

2.В файл сайт.ru/catalog/catalog/controller/account/account.php добавить:
$this->load->model('total/shoputils_cumulative_discounts');
$this->language->load('module/shoputils_cumulative_discounts_');
$this->data['heading_title'] = $this->language->get('heading_title');
$this->data['text_customer'] = $this->customer->getFirstname() . ' ' . $this->customer->getLastname();
$this->data['href_discounts'] = HTTP_SERVER.'index.php?route=module/shoputils_cumulative_discounts_/discounts';

if ($discount = $this->model_total_shoputils_cumulative_discounts->getLoggedCustomerDiscount() ){
if ($discount['description']){
$this->data['text_description'] = $discount['description'];
} else {
$this->data['text_description'] = $this->language->get('text_description_empty');
}
$this->data['text_href_discounts'] = $this->language->get('text_href_discounts_logged');
$this->data['text_cumulative_summ'] = sprintf($this->language->get('text_cumulative_summ'), $this->currency->format($discount['cumulative_summ']));
} else {
$this->data['text_description'] = $this->language->get('text_description_none');;
$this->data['text_href_discounts'] = $this->language->get('text_href_discounts_not_logged');
}
ФСЁ.
 
Назад
Сверху