$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; } else { $categoriesNames = array(); foreach ($allCategories as $k => $allCategory) { if (in_array($allCategory['id_category'], $voucherCategories)) {
/** * 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'); }
// + 1 year $voucher->minimal = 0; $voucher->active = 1; $languages = Language::getLanguages(true); $default_text = Configuration::get('PS_LOYALTY_VOUCHER_DETAILS', intval(Configuration::get('PS_LANG_DEFAULT'))); foreach ($languages as $language) { $text = Configuration::get('PS_LOYALTY_VOUCHER_DETAILS', intval($language['id_lang'])); $voucher->description[intval($language['id_lang'])] = $text ? strval($text) : strval($default_text); } $voucher->save(); /* register order(s) which contribute to create this voucher */ LoyaltyModule::registerDiscount($voucher); Tools::redirect('modules/loyalty/loyalty-program.php'); } include dirname(__FILE__) . '/../../header.php'; $orders = LoyaltyModule::getAllByIdCustomer(intval($cookie->id_customer), intval($cookie->id_lang)); $smarty->assign(array('orders' => $orders, 'totalPoints' => $customerPoints, 'voucher' => LoyaltyModule::getVoucherValue($customerPoints, intval($cookie->id_currency)), 'validation_id' => LoyaltyStateModule::getValidationId(), 'transformation_allowed' => $customerPoints > 0)); /* Discounts */ $nbDiscounts = 0; $discounts = array(); if ($ids_discount = LoyaltyModule::getDiscountByIdCustomer(intval($cookie->id_customer))) { $nbDiscounts = count($ids_discount); foreach ($ids_discount as $key => $discount) { $discounts[$key] = new Discount($discount['id_discount'], intval($cookie->id_lang)); $discounts[$key]->date_add = $discount['date_add']; $discounts[$key]->orders = LoyaltyModule::getOrdersByIdDiscount($discount['id_discount']); } } $smarty->assign(array('nbDiscounts' => $nbDiscounts, 'discounts' => $discounts)); echo Module::display(dirname(__FILE__) . '/loyalty.php', 'loyalty.tpl'); include dirname(__FILE__) . '/../../footer.php';