public function execute() { $userService = ServiceFactory::factory('User'); $username = is_null($this->getParam('uname')) ? '' : trim($this->getParam('uname')); if (empty($username)) { $this->setError(KancartResult::ERROR_USER_INPUT_PARAMETER, 'User name is empty.'); return; } $encryptedPassword = is_null($this->getParam('pwd')) ? '' : trim($this->getParam('pwd')); $password = CryptoUtil::Crypto($encryptedPassword, 'AES-256', KANCART_APP_SECRET, false); if (!$password) { $this->setError(KancartResult::ERROR_USER_INPUT_PARAMETER, 'Password is empty.'); return; } $loginInfo = array('email' => $username, 'password' => $password); $login = $userService->login($loginInfo); if (is_string($login)) { $this->setError(KancartResult::ERROR_USER_INPUT_PARAMETER, $login); return; } $cacheKey = $this->customer->getCustomerGroupId() . '-' . $this->config->get('config_customer_price'); if ($this->config->get('config_tax')) { $query = $this->db->query("SELECT gz.geo_zone_id FROM " . DB_PREFIX . "geo_zone gz LEFT JOIN " . DB_PREFIX . "zone_to_geo_zone z2gz ON (z2gz.geo_zone_id = gz.geo_zone_id) WHERE (z2gz.country_id = '0' OR z2gz.country_id = '" . (int) $this->customer->country_id . "') AND (z2gz.zone_id = '0' OR z2gz.zone_id = '" . (int) $this->customer->zone_id . "')"); if ($query->num_rows) { $cacheKey .= '-1-' . $query->row['geo_zone_id']; } else { $cacheKey .= '-1-0'; } } else { $cacheKey .= '-0-0'; } $info = array('sessionkey' => md5($username . uniqid(mt_rand(), true)), 'cachekey' => $cacheKey); $this->setSuccess($info); }
public function execute() { switch ($_REQUEST['checkout_type']) { case 'cart': if ($_REQUEST['payment_method_id'] == 'paypal') { $actionInstance = ActionFactory::factory('KanCart.ShoppingCart.PayPalWPS.Done'); $actionInstance->init(); $actionInstance->execute(); $this->result = $actionInstance->getResult(); } else { $kancartPaymentService = ServiceFactory::factory('KancartPayment'); list($result, $order_id) = $kancartPaymentService->kancartPaymentDone($_REQUEST['order_id'], $_REQUEST['custom_kc_comments'], $_REQUEST['payment_status']); if ($result === TRUE) { $orderService = ServiceFactory::factory('Order'); $info = $orderService->getPaymentOrderInfoById($order_id); $this->setSuccess($info); } else { $this->setError('0xFFFF', $order_id); } } case 'order': break; default: break; } }
public function execute() { $userService = ServiceFactory::factory('User'); $username = is_null($this->getParam('email')) ? '' : trim($this->getParam('email')); $enCryptedPassword = is_null($this->getParam('pwd')) ? '' : trim($this->getParam('pwd')); $password = CryptoUtil::Crypto($enCryptedPassword, 'AES-256', KANCART_APP_SECRET, false); $this->language->load('account/register'); if (strlen(utf8_decode($username)) > 96 || !preg_match('/^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,3})$/i', $username)) { $this->setError(KancartResult::ERROR_USER_INVALID_USER_DATA, $this->language->get('error_email')); return; } if (strlen($password) < 4 || strlen($password) > 20) { $this->setError(KancartResult::ERROR_USER_INVALID_USER_DATA, $this->language->get('error_password')); return; } $firstname = is_null($this->getParam('firstname')) ? '' : trim($this->getParam('firstname')); $lastname = is_null($this->getParam('lastname')) ? '' : trim($this->getParam('lastname')); $telephone = is_null($this->getParam('telephone')) ? '' : trim($this->getParam('telephone')); $regisetInfo = array('firstname' => $firstname, 'lastname' => $lastname, 'email' => $username, 'telephone' => $telephone, 'password' => $password); if (!$userService->register($regisetInfo)) { $this->setError(KancartResult::ERROR_USER_INVALID_USER_DATA, $msg); return; } // succed registering $this->setSuccess(); }
public function execute() { $cartItemId = $this->getParam('cart_item_id'); $cartService = ServiceFactory::factory('ShoppingCart'); $cartService->remove($cartItemId); $this->setSuccess($cartService->get()); }
public function execute() { $checkoutService = ServiceFactory::factory('Checkout'); $couponCode = $_REQUEST['coupon_id']; $checkoutService->updateCoupon($couponCode); $this->setSuccess($checkoutService->detail()); }
public function execute() { $orderId = $this->getParam('order_id'); $orderService = ServiceFactory::factory('Order'); $oneOrderInfo = $orderService->getOneOrderInfoById($orderId); $this->setSuccess(array('order' => $oneOrderInfo)); }
public function execute() { if (!$this->cart->hasProducts()) { $this->setSuccess(array('redirect_to_page' => 'shopping_cart', 'messages' => array('Shopping Cart is empty.'))); return; } $this->setSuccess(ServiceFactory::factory('Checkout')->detail()); }
public function execute() { $shippingMethodId = $this->getParam('shipping_method_id'); if ($shippingMethodId) { $checkoutService = ServiceFactory::factory('Checkout'); $checkoutService->updateShippingMethod($shippingMethodId); } $this->setSuccess($checkoutService->detail()); }
public function execute() { $pageNo = $this->getParam('page_no'); $pageSize = $this->getParam('page_size'); $parameter = array('page_no' => isset($pageNo) && is_numeric($pageNo) ? intval($pageNo) : 1, 'page_size' => isset($pageSize) && is_numeric($pageSize) ? intval($pageSize) > 30 ? 30 : intval($pageSize) : 10, 'status_id' => $this->getParam('status_id'), 'customer_id' => $_SESSION['customer_id']); $orderService = ServiceFactory::factory('Order'); $orderInfos = $orderService->getOrderInfos($parameter); $this->setSuccess($orderInfos); }
public function execute() { $order_id = $this->session->data['order_id']; $paypalWpsService = ServiceFactory::factory('PaypalWps'); $paypalWpsService->paypalWpsDone(); $tx = max($_REQUEST['tx'], $_REQUEST['txn_id']); $orderService = ServiceFactory::factory('Order'); $info = $orderService->getPaymentOrderInfoById($order_id, $tx); $this->setSuccess($info); }
public function execute() { $userService = ServiceFactory::factory('User'); $address = prepare_address(); $updateResult = $userService->updateAddress($address); if ($updateResult === true) { $this->setSuccess(); return; } $this->setError(KancartResult::ERROR_USER_INPUT_PARAMETER, join(',', $updateResult)); }
public function execute() { $productId = intval($this->getParam('item_id')); $productService = ServiceFactory::factory('Product'); $product = $productService->getProduct($productId); if ($product) { $this->setSuccess(array('item' => $product)); } else { $this->setError(KancartResult::ERROR_ITEM_INPUT_PARAMETER); } }
public function execute() { $pageNo = intval($_REQUEST['page_no']) - 1; $pageSize = intval($_REQUEST['page_size']); $itemId = intval($_REQUEST['item_id']); if ($pageSize <= 0) { $pageSize = 10; } $reviewService = ServiceFactory::factory('Review'); $reviews = $reviewService->getReviews($itemId, $pageNo, $pageSize); $reviewCounts = $reviewService->getReviewsCount($itemId); $this->setSuccess(array('trade_rates' => $reviews, 'total_results' => $reviewCounts)); }
/** * get products information * @param type $cart * @return array * @author hujs */ public function getProducts() { $currency = $this->currency->getCode(); $items = array(); $productService = ServiceFactory::factory('Product'); $products = $this->cart->getProducts(); foreach ($products as $product) { $productInfo = $productService->getProduct($product['product_id']); $item = array('cart_item_id' => $product['key'], 'cart_item_key' => '', 'item_id' => $product['product_id'], 'item_title' => $productInfo['item_title'] . (!$product['stock'] ? '<font color = \'red\'>***' : ''), 'thumbnail_pic_url' => $productInfo['thumbnail_pic_url'], 'currency' => $currency, 'item_price' => $this->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax'))), 'qty' => $product['quantity'], 'display_attributes' => $this->getDisplayAttributes($product['option']), 'item_url' => $productInfo['item_url'], 'short_description' => $productInfo['short_description']); $items[] = $item; } return $items; }
public function execute() { $userService = ServiceFactory::factory('User'); $addressBookId = intval($this->getParam('address_book_id')); if ($addressBookId) { $result = $userService->deleteAddress($addressBookId); if (true === $result) { $this->setSuccess(); return; } $this->setError(KancartResult::ERROR_USER_INPUT_PARAMETER, join(',', $result)); } $this->setError(KancartResult::ERROR_USER_INPUT_PARAMETER, 'Address book is empty'); }
public function execute() { $username = is_null($this->getParam('email')) ? '' : trim($this->getParam('email')); if (strlen($username) == 0) { $this->setError(KancartResult::ERROR_USER_INPUT_PARAMETER); return; } $response = array(); $response['nick_is_exist'] = "false"; $response['uname_is_exist'] = "false"; $userService = ServiceFactory::factory('User'); if ($userService->checkEmailExists($username)) { $response['uname_is_exist'] = "true"; } $this->setSuccess($response); }
public function execute() { $itemId = $this->getParam('item_id'); $rating = is_null($this->getParam('rating')) ? 5 : intval($this->getParam('rating')); if ($rating > 5) { $rating = 5; } elseif ($rating < 0) { $rating = 0; } $content = is_null($this->getParam('content')) ? '' : htmlspecialchars(substr(trim($this->getParam('content')), 0, 1000)); $reviewService = ServiceFactory::factory('Review'); if ($reviewService->addReview($itemId, $content, $rating)) { $this->setSuccess(); } else { $this->setError('', 'add review to this product failed.'); } }
/** new * get user orders information * @param type $userId * @return type * @author hujs */ public function getOrderInfos(array $parameter) { $orderInfos = array(); $userId = $parameter['customer_id']; $pageNo = $parameter['page_no']; $pageSize = $parameter['page_size']; $orders = $this->getOrderList($pageNo, $pageSize); foreach ($orders as $order) { $orderItem = array(); $this->initOrderDetail($orderItem, $order); $orderItem['price_infos'] = $this->getPriceInfos($orderItem, $order); $orderItem['order_items'] = $this->getOrderItems($order); $orderItem['order_status'] = ServiceFactory::factory('Store')->getOrderStatauses(); $orderInfos[] = $orderItem; } return array('total_results' => $this->getUserOrderCounts($userId), 'orders' => $orderInfos); }
public function placeOrder($method) { $this->session->data['payment_method'] = array('id' => 'mobile', 'title' => $method, 'sort_order' => 1); $paypal = ServiceFactory::factory('PaypalWps'); list($result, $mesg) = $paypal->placeOrder(); $order_id = $this->session->data['order_id']; $this->load->model('checkout/order'); if ($result === true) { $comments = 'From mobile payment ' . $method; $this->model_checkout_order->confirm($this->session->data['order_id'], $this->config->get('config_order_status_id'), $comments); $paypal->paypalWpsDone(); return array(true, $order_id, array()); } else { $message = is_array($mesg) ? join('<br>', $mesg) : $mesg; return array(false, $order_id, $message); } }
public function execute() { $cartItemId = $this->getParam('cart_item_id'); $qty = intval($this->getParam('qty')) > 0 ? intval($this->getParam('qty')) : 1; $cartService = ServiceFactory::factory('ShoppingCart'); if (method_exists($cartService, 'checkMinimunOrder')) { $error = $cartService->checkMinimunOrder(intval($cartItemId), $qty); } else { $error = array(); } if (is_array($error) && sizeof($error) == 0) { $cartService->update($cartItemId, $qty); $result = $cartService->get(); } else { $result = $cartService->get(); $result['messages'] = $error; } $this->setSuccess($result); }
public function execute() { $shippingAddressBookId = max($_REQUEST['shipping_address_book_id'], $_REQUEST['billing_address_book_id']); $shippingAddressJson = max($_REQUEST['shipping_address'], $_REQUEST['billing_address']); if ($shippingAddressBookId) { $shippingAddress = array(); if ($shippingAddressJson) { $shippingAddressJson = htmlspecialchars_decode($shippingAddressJson, ENT_COMPAT); $this->exportAddressToRequest(json_decode($shippingAddressJson, true)); $shippingAddress = prepare_address(); } $this->updateAddress($shippingAddressBookId, $shippingAddress); } else { //add a new address to db $shippingAddressJson = htmlspecialchars_decode($shippingAddressJson, ENT_COMPAT); $this->exportAddressToRequest(json_decode($shippingAddressJson, true)); $this->addAddress(prepare_address()); } $this->setSuccess(ServiceFactory::factory('Checkout')->detail()); }
public function isSortByAllowed($sortBy) { if (!$sortBy) { return false; } $storeService = ServiceFactory::factory('Store'); $orderByFound = false; foreach ($storeService->getCategorySortOptions() as $options) { foreach ($options as $option) { if ($option['code'] == $sortBy) { $orderByFound = true; break; } } if ($orderByFound) { break; } } return $orderByFound; }
public function execute() { $categoryService = ServiceFactory::factory('Category'); $categories = $categoryService->getAllCategories(); if (isset($_REQUEST['all_cat'])) { $this->setSuccess(array('item_cats' => $categories)); return; } else { if (!isset($_REQUEST['parent_cid'])) { $this->setError(KancartResult::ERROR_CATEGORY_INPUT_PARAMETER); return; } $parent_cid = -1; if ($_REQUEST['parent_cid'] != -1) { $parent_cid = $_REQUEST['parent_cid']; } $info = $categoryService->getSubCategories($parent_cid, $categories); $this->setSuccess(array('item_cats' => $info)); return; } }
public function execute() { $itemId = $this->getParam('item_id'); $qty = $this->getParam('qty'); $attributes = $_REQUEST['attributes']; $option = array(); if ($attributes) { $attributes = str_replace('\\', '/', htmlspecialchars_decode($attributes, ENT_COMPAT)); $attributes = json_decode(stripslashes(urldecode($attributes))); foreach ($attributes as $attribute) { $optionId = $attribute->attribute_id; if ($attribute->input == 'multiselect') { //support checkbox array() $option[$optionId] = explode(',', $attribute->value); } else { $option[$optionId] = $attribute->value; } } } $cartService = ServiceFactory::factory('ShoppingCart'); if (method_exists($cartService, 'checkMinimunOrder')) { $error = $this->beforeAction($itemId, $option, $qty, $cartService); } else { $error = true; } if ($error === true) { $cartService->add($itemId, $qty, $option); $result = $cartService->get(); $result['messages'] = array(); //do not show not in stock message } else { $result = $cartService->get(); $result['messages'] = $error; } $this->setSuccess($result); }
public function updateAddress($addressBookId, $address = array()) { if ($this->customer->isLogged()) { if ($addressBookId) { if ($address) { $address['address_id'] = $addressBookId; $userService = ServiceFactory::factory('User'); $userService->updateAddress($address); } //for now,keep the two address same $this->session->data['shipping_address_id'] = $addressBookId; $this->session->data['payment_address_id'] = $addressBookId; unset($this->session->data['shipping_methods']); unset($this->session->data['shipping_method']); } } }
public function execute() { $service = ServiceFactory::factory('User'); $addresses = $service->getAddresses(); $this->setSuccess(array("addresses" => $addresses)); }
/** * Get one product info * @param integer $goods_id 商品id * @return array * @author hujs */ public function getProduct($productId) { $this->load->model('catalog/product'); $row = $this->model_catalog_product->getProduct($productId); if ($row) { $productTranslator = ServiceFactory::factory('ProductTranslator'); $productTranslator->setProduct($row); return $productTranslator->getFullItemInfo(); } return array(); }
public function execute() { $this->setSuccess(array('order_counts' => array(array('status_ids' => 'all', 'status_name' => 'My Orders', 'count' => ServiceFactory::factory('Order')->getUserOrderCounts())))); }
public function getRelatedItems() { $relatedItems = array(); $rows = $this->model_catalog_product->getProductRelated($this->product['product_id']); $proudctTranslator = ServiceFactory::factory('ProductTranslator', false); foreach ($rows as $row) { $proudctTranslator->clear(); $proudctTranslator->setProduct($row); $proudctTranslator->getItemBaseInfo(); $proudctTranslator->getItemPrices(); $relatedItems[] = $proudctTranslator->getTranslatedItem(); } $this->item['related_items'] = $relatedItems; }
public function execute() { $storeService = ServiceFactory::factory('Store'); $this->setSuccess($storeService->getStoreInfo()); }