/** * Assign summary template */ public function assignSummaryExecution() { $customer_points = (int) LoyaltyModule::getPointsByCustomer((int) $this->context->customer->id); $orders = LoyaltyModule::getAllByIdCustomer((int) $this->context->customer->id, (int) $this->context->language->id); $displayorders = LoyaltyModule::getAllByIdCustomer((int) $this->context->customer->id, (int) $this->context->language->id, false, true, (int) Tools::getValue('n') > 0 ? (int) Tools::getValue('n') : 10, (int) Tools::getValue('p') > 0 ? (int) Tools::getValue('p') : 1); $this->context->smarty->assign(array('orders' => $orders, 'displayorders' => $displayorders, 'totalPoints' => (int) $customer_points, 'voucher' => LoyaltyModule::getVoucherValue($customer_points, (int) $this->context->currency->id), 'validation_id' => LoyaltyStateModule::getValidationId(), 'transformation_allowed' => $customer_points > 0, 'page' => (int) Tools::getValue('p') > 0 ? (int) Tools::getValue('p') : 1, 'nbpagination' => (int) Tools::getValue('n') > 0 ? (int) Tools::getValue('n') : 10, 'nArray' => array(10, 20, 50), 'max_page' => floor(count($orders) / ((int) Tools::getValue('n') > 0 ? (int) Tools::getValue('n') : 10)), 'pagination_link' => $this->getSummaryPaginationLink(array(), $this->context->smarty))); /* Discounts */ $nb_discounts = 0; $discounts = array(); if ($ids_discount = LoyaltyModule::getDiscountByIdCustomer((int) $this->context->customer->id)) { $nb_discounts = count($ids_discount); foreach ($ids_discount as $key => $discount) { $discounts[$key] = new CartRule((int) $discount['id_cart_rule'], (int) $this->context->cookie->id_lang); $discounts[$key]->orders = LoyaltyModule::getOrdersByIdDiscount((int) $discount['id_cart_rule']); } } $all_categories = Category::getSimpleCategories((int) $this->context->cookie->id_lang); $voucher_categories = Configuration::get('PS_LOYALTY_VOUCHER_CATEGORY'); if ($voucher_categories != '' && $voucher_categories != 0) { $voucher_categories = explode(',', Configuration::get('PS_LOYALTY_VOUCHER_CATEGORY')); } else { die(Tools::displayError()); } if (count($voucher_categories) == count($all_categories)) { $categories_names = null; } else { $categories_names = array(); foreach ($all_categories as $k => $all_category) { if (in_array($all_category['id_category'], $voucher_categories)) { $categories_names[$all_category['id_category']] = trim($all_category['name']); } } if (!empty($categories_names)) { $categories_names = Tools::truncate(implode(', ', $categories_names), 100) . '.'; } else { $categories_names = null; } } $this->context->smarty->assign(array('nbDiscounts' => (int) $nb_discounts, 'discounts' => $discounts, 'minimalLoyalty' => (double) Configuration::get('PS_LOYALTY_MINIMAL'), 'categories' => $categories_names)); $this->setTemplate('loyalty.tpl'); }
$cartRule->add(); } /* Register order(s) which contributed to create this voucher */ if (!LoyaltyModule::registerDiscount($cartRule)) { $cartRule->delete(); } Tools::redirect('modules/loyalty/loyalty-program.php'); } include dirname(__FILE__) . '/../../header.php'; $orders = LoyaltyModule::getAllByIdCustomer((int) $cookie->id_customer, (int) $cookie->id_lang); $displayorders = LoyaltyModule::getAllByIdCustomer((int) $cookie->id_customer, (int) $cookie->id_lang, false, true, (int) Tools::getValue('n') > 0 ? (int) Tools::getValue('n') : 10, (int) Tools::getValue('p') > 0 ? (int) Tools::getValue('p') : 1); $smarty->assign(array('orders' => $orders, 'displayorders' => $displayorders, 'pagination_link' => __PS_BASE_URI__ . 'modules/loyalty/loyalty-program.php', 'totalPoints' => (int) $customerPoints, 'voucher' => LoyaltyModule::getVoucherValue($customerPoints, (int) $context->currency->id), 'validation_id' => LoyaltyStateModule::getValidationId(), 'transformation_allowed' => $customerPoints > 0, 'page' => (int) Tools::getValue('p') > 0 ? (int) Tools::getValue('p') : 1, 'nbpagination' => (int) (Tools::getValue('n') > 0) ? (int) Tools::getValue('n') : 10, 'nArray' => array(10, 20, 50), 'max_page' => floor(sizeof($orders) / ((int) (Tools::getValue('n') > 0) ? (int) Tools::getValue('n') : 10)))); /* Discounts */ $nbDiscounts = 0; $discounts = array(); if ($ids_discount = LoyaltyModule::getDiscountByIdCustomer((int) $cookie->id_customer)) { $nbDiscounts = count($ids_discount); foreach ($ids_discount as $key => $discount) { $discounts[$key] = new Discount((int) $discount['id_cart_rule'], (int) $cookie->id_lang); $discounts[$key]->orders = LoyaltyModule::getOrdersByIdDiscount((int) $discount['id_cart_rule']); } } $allCategories = Category::getSimpleCategories((int) $cookie->id_lang); $voucherCategories = Configuration::get('PS_LOYALTY_VOUCHER_CATEGORY'); if ($voucherCategories != '' and $voucherCategories != 0) { $voucherCategories = explode(',', Configuration::get('PS_LOYALTY_VOUCHER_CATEGORY')); } else { die(Tools::displayError()); } if (sizeof($voucherCategories) == sizeof($allCategories)) { $categoriesNames = null;