Пример #1
0
 static function generateGiftCardProduct($controller, $fid)
 {
     $obj = new EcommerceProduct();
     $obj->setFriendlyId($fid);
     $obj->setIsIgnoreStock(TRUE);
     $obj->setTitle('Gift Card');
     $obj->setIsFreeShipping(TRUE);
     $imageUrl = $controller->getDepConfigValue('giftcard_image_url');
     if ($imageUrl) {
         $obj->setImages(array($controller->composeLink($imageUrl)));
     }
     $obj->__detailsLink = '/gift_card';
     $obj->__calculatePrice = function ($controller, $cartItem, $member, $product) {
         return Helper_Krco::calculatePriceGiftCard($controller, $cartItem, $member, $product);
     };
     return $obj;
 }
Пример #2
0
 static function _getSubNavFromArticleLabel($label, $controller)
 {
     $subNav = array();
     $articles = $controller->dbCall('articles', 'getArticlesByLabel', array($label), TRUE);
     if ($articles) {
         $subNav = Helper_Krco::buildNavFromArticles($controller, $label, $articles);
         /*
         foreach ($articles as $art) {
             $fid = $art->getFriendlyId();
             $key = "$label/$fid";
             $subNav[$key] = array(
                 'title' => $art->getTitle($controller->lang),
                 'link' => self::composeArticleLink($controller, $label, $fid)
             );
         }
         */
     }
     return $subNav;
 }
Пример #3
0
 static function getCompleteRoutes($preparer, $routes)
 {
     $controller = new Krco_Articles();
     $preparer->prepareController($controller);
     $articleLabels = $controller->getObjects('articles', 'getAllLabels', array());
     foreach ($articleLabels as $label) {
         $segment = str_replace(' ', '_', $label);
         if (!isset($routes[$segment])) {
             $routes[$segment] = Helper_Krco::createArticleRoute($segment);
         }
     }
     return $routes;
 }
Пример #4
0
 function getCartText($text)
 {
     return Helper_Krco::getText($this->messages, $text);
 }
Пример #5
0
 function getMessage($index)
 {
     return Helper_Krco::getText(isset($this->messages) ? $this->messages : array(), $index);
 }
Пример #6
0
    static function cancelOrder($controller, $order, $setRemarks = NULL)
    {
        if (isset($setRemarks)) {
            $order->setRemarks($setRemarks);
        }
        $withCancelOrders = $controller->getKrcoConfigValue('cart', 'with_cancel_orders');
        if ($withCancelOrders === FALSE) {
            return;
        }
        if ($order->getOrderStatus() == 'Cancelled') {
            return;
        }
        $currentStatus = $order->getOrderStatus();
        $order->setOrderStatus('Cancelled');
        $controller->dbCall('orders', 'updateOrder', array($order), TRUE);
        $orderedProds = $order->getOrderedProducts();
        foreach ($orderedProds as $orderedProd) {
            $item = self::_orderedProdToItem($orderedProd);
            Helper_Cart::_subtractProductStock($item, $controller, TRUE);
        }
        $memberObj = $controller->getMemberOfOrder($order);
        $controller->_processMemberPlaceOrder($order, $memberObj, TRUE);
        //revert back point earned if any
        if ($currentStatus == 'Processing') {
            self::_setMemberPoint($controller, $order, $memberObj, TRUE);
        }
        $signature = $controller->_getEmailSignature();
        $from = $controller->getNoReplyFrom();
        $to = $controller->getOrdersEmailAddress();
        $orderId = $order->getLongId();
        $orderManageLine = Helper_Krco::getOrderManageLine($controller, $order);
        $body = <<<EOD
<p>
Dear Admin,
</p>
<p>
This is to notify that the Order with ID {$orderId} is expired.
</p>
<p>
{$orderManageLine}
</p>
{$signature}

EOD;
        Helper_Mail::sendEmail($controller, $from, $to, NULL, NULL, "Expired Order: {$orderId}", $controller->_getHtmlEmailBody($body));
        $name = $order->getRecipientName();
        $userBody = $controller->_getOrderExpiredEmailBodyToUser($order);
        $smsBody = $controller->getOrderExpiredSmsBodyToUser($order);
        $emails = $controller->_getOrderEmails($order);
        Helper_Mail::sendEmailWithFooter($controller, $from, $emails['to'], $emails['cc'], NULL, "Expired Order: {$orderId}", $userBody);
        Helper_Mail::sendSms($controller, $order->getRecipientPhoneNumber(), $smsBody);
    }
Пример #7
0
 static function _ecommerceProductToArr($controller, $obj)
 {
     $arr = self::_basicProductToArr($controller, $obj);
     if (!$obj instanceof EcommerceProduct) {
         return $arr;
     }
     $tempSimpleProducts = Helper_Krco::getSimpleProductsByAggregatorId($controller, $obj->getId());
     $simpleProducts = array();
     foreach ($tempSimpleProducts as $simProd) {
         $newSimProd = Helper_Cart::_combineSimpleFromAggregator($simProd, $obj);
         $simpleProducts[] = $newSimProd;
     }
     $arr['decoration'] = $obj->getRibbon();
     $arr['wish_count'] = (int) $obj->getWishCount();
     $arr['options'] = $controller->_getProductOptions($obj);
     $arr['general_options'] = $controller->_getProductGeneralOptions($arr['options']);
     $arr['is_backorder'] = Helper_Structure::_getAttrFromObj('IsAllowBackorder', $obj);
     $arr['variants'] = $controller->_getProductVariants($obj, $simpleProducts);
     $arr['detailed_variants'] = $controller->_getProductVariants($obj, $simpleProducts, TRUE);
     $arr['prices_by_color'] = $controller->_getPricesByColor($obj, $simpleProducts);
     $arr['advanced_pricing_rules'] = json_decode($obj->getAdvancedPricingRule(), TRUE);
     $arr['size'] = $obj->getAttribute1();
     $arr['color'] = $obj->getAttribute2();
     //$arr['material'] = $obj->getAttribute3();
     $options = $controller->getObjKrcoConfig('options', 'products');
     if (is_array($options)) {
         $idx = 3;
         $defKeys = Helper_Krco::getDefaultProductOptionKeys();
         foreach ($options as $key => $opt) {
             if (in_array($key, $defKeys)) {
                 continue;
             }
             $getAttr = "getAttribute{$idx}";
             $arr[$key] = $obj->{$getAttr}();
             $idx++;
         }
     }
     return $arr;
 }
Пример #8
0
 static function getTestProduct($controller, $idx)
 {
     $short_description = Helper_ViewTest::getLoremIpsumP(1) . "\n" . Helper_ViewTest::getLoremIpsumP(1);
     if ($idx % 2) {
         $short_description = "<p>Very short description.</p>\n";
     }
     $description = Helper_ViewTest::getLoremIpsumP(2) . "\n" . Helper_ViewTest::getLoremIpsumP(1);
     if ($idx > 3) {
         $description = Helper_ViewTest::getLoremIpsumP(1);
     }
     $attachment = "http://attachment{$idx}";
     $product = array('id' => $idx, 'fid' => "product-{$idx}", 'product_code' => "ABC{$idx}", 'title' => "Product {$idx}" . ($idx % 2 ? " Long Long Very Long Name" : ''), 'short_description' => $short_description, 'description' => $description, 'brand' => "Brand {$idx}", 'label' => "Category " . (($idx - 1) % 3 + 1), 'label_fid' => "parent/category" . (($idx - 1) % 3 + 1), 'specification' => self::_getTestProductSpecification(), 'link' => "http://product{$idx}", 'price_raw' => $idx == 16 ? 0 : $idx * 500, 'is_new' => !(bool) ($idx % 3), 'is_featured' => !(bool) ($idx % 2), 'size' => "Size {$idx}", 'color' => "Color {$idx}", 'images' => array($controller->resource_url . "/images/test/product_{$idx}a.jpg", $controller->resource_url . '/images/test/product_b.jpg', $controller->resource_url . '/images/test/product_a.jpg', $controller->resource_url . '/images/test/product_b.jpg', $controller->resource_url . '/images/test/product_a.jpg', $controller->resource_url . '/images/test/product_b.jpg'), 'detailed_images' => self::_getTestDetailedImages($controller, 12));
     if ($idx == 8) {
         $product['label'] = 'Backorder';
     }
     if (!($idx % 2)) {
         $product['images'] = array($controller->resource_url . "/images/test/product_{$idx}a.jpg", $controller->resource_url . '/images/test/product_b.jpg');
         $product['detailed_images'] = self::_getTestDetailedImages($controller, 4);
     }
     if ($idx == 6) {
         $product['images'] = array();
         $product['detailed_images'] = array();
     }
     if ($idx % 2) {
         $product['attachment'] = $attachment;
     }
     if (isset($controller->krcoFunctions) && method_exists($controller->krcoFunctions, 'appendProduct')) {
         $controller->krcoFunctions->appendProduct($idx, $product);
     }
     $options = $controller->getObjKrcoConfig('options', 'products');
     if (is_array($options)) {
         $defKeys = Helper_Krco::getDefaultProductOptionKeys();
         foreach ($options as $key => $opt) {
             if (!in_array($key, $defKeys)) {
                 $product[$key] = "{$key} {$idx}";
             }
         }
     }
     $product = array_merge($product, Helper_ViewTest::getAdditionalTestFields($controller, 'products', $idx));
     if ($idx % 2) {
         //$product['usual_price'] = '$ ' . ($idx*500+50);
         $product['usual_price_raw'] = $idx * 500 + 50;
         $product['sale_expiry_timestamp'] = $idx * 86400;
     }
     return $product;
 }