/**
  * Returns all available shipping methods for the current cart
  * together with the appropriate prices
  *
  * Sample return
  * return array(
  *  'flat_rate_shipping' => 'Flat rate shipping 10$'
  * , 'ups__01' => 'UPS Domestic bla bla 5$'
  * , 'ups__65' => 'UPS International saver 4$'
  * )
  */
 public function getAvailableShippingMethodsAndTheirPrices($module_srl, Cart $cart)
 {
     $cache_key = 'available_shipping_' . $module_srl . '_' . $cart->cart_srl;
     $available_shipping_methods = self::$cache->get($cache_key);
     if (!$available_shipping_methods) {
         $shop_info = new ShopInfo($module_srl);
         $active_shipping_methods = $this->getActiveShippingMethods($module_srl);
         $available_shipping_methods = array();
         foreach ($active_shipping_methods as $shipping_method) {
             $available_variants = $shipping_method->getAvailableVariants($cart);
             foreach ($available_variants as $variant) {
                 if (!$variant->price) {
                     $key = "";
                     $value = $variant->display_name . ' - ' . $variant->variant_display_name;
                 } else {
                     $key = $variant->name;
                     if ($variant->variant) {
                         $key .= '__' . $variant->variant;
                     }
                     $value = $variant->display_name;
                     if ($variant->variant) {
                         $value .= ' - ' . $variant->variant_display_name;
                     }
                     $value .= ' - ' . ShopDisplay::priceFormat($variant->price, $shop_info->getCurrencySymbol());
                 }
                 $available_shipping_methods[$key] = $value;
             }
         }
         self::$cache->set($cache_key, $available_shipping_methods);
     }
     return $available_shipping_methods;
 }
Exemplo n.º 2
0
    /**
     * Shop return list
     * @param $args
     * @return object
     */
    public function getShopList($args)
	{
		$output = executeQueryArray('shop.getShopList', $args);
		if(!$output->toBool())
		{
			return $output;
		}

		if(count($output->data))
		{
			foreach($output->data as $key => $val)
			{
				$oShop = NULL;
				$oShop = new ShopInfo();
				$oShop->setAttribute($val);
				$output->data[$key] = NULL;
				$output->data[$key] = $oShop;
			}
		}
		return $output;
	}
Exemplo n.º 3
0
 /**
  * Updates product category count
  * @param $args
  * @throws ShopException
  */
 public function updateProductCategoryCount($args)
 {
     $shopInfo = new ShopInfo($args->module_srl);
     // Get number of products in category
     $args->status = "enabled";
     if ($shopInfo->getOutOfStockProducts() == 'N') {
         $args->in_stock = "Y";
     }
     $count_output = executeQuery('shop.getProductsInCategoryCount', $args);
     if (!$count_output->toBool()) {
         throw new ShopException($count_output->getMessage(), $count_output->getError());
     }
     // Update product count
     $update_args = new stdClass();
     $update_args->category_srl = $args->category_srl;
     $update_args->product_count = $count_output->data->product_count;
     $output = executeQuery('shop.updateCategory', $update_args);
     if (!$output->toBool()) {
         throw new ShopException($output->getMessage(), $output->getError());
     }
 }
Exemplo n.º 4
0
 /**
  * Check if product is available
  *
  * TODO When accesing availability like this: $cart_product->available
  * the default value for $checkIfInStock=true is used; This in not always correct! To investigate
  *
  * @internal param bool $checkIfInStock
  * @return bool
  */
 public function isAvailable()
 {
     $shopInfo = new ShopInfo($this->product->module_srl);
     $checkIfInStock = $shopInfo->getOutOfStockProducts() == 'Y';
     if ($this->product->isPersisted()) {
         return $this->product->isAvailable($checkIfInStock);
     }
     return FALSE;
 }
Exemplo n.º 5
0
 public static function modifyArriveTime($order_id, $washing_time)
 {
     $criteria = new CDbCriteria();
     $criteria->condition = "order_id='" . $order_id . "'";
     $record_odr = CarWashOrderInfo::model()->find($criteria);
     $record_odr->washing_time = $washing_time;
     $is_save = $record_odr->save();
     $criteria = new CDbCriteria();
     $criteria->select = "service_name";
     $criteria->condition = "service_id='" . $record_odr->shop_id . "'";
     $record_tpe = CarWashType::model()->find($criteria);
     $criteria = new CDbCriteria();
     $criteria->select = "shop_name";
     $criteria->condition = "shop_id='" . $record_odr->shop_id . "'";
     $record_shp = ShopInfo::model()->find($criteria);
     $criteria = new CDbCriteria();
     $criteria->condition = "shop_id='" . $record_odr->shop_id . "' and consume_status=0";
     $record_odrs = CarWashOrderInfo::model()->findAll($criteria);
     if ($record_odr == null || $record_tpe == null || $record_shp == null || $is_save == false) {
         $ret_json = array("status" => 1, "message" => "修改预约时间失败!", "data" => array());
     } else {
         $ret_json = array("status" => 0, "message" => "预约成功!", "data" => array("status" => 1, "shopname" => $record_shp->shop_name, "ordername" => $record_tpe->service_name, "ordernum" => $order_id, "ordertime" => $washing_time, "waiting" => count($record_odrs) - 1));
     }
     return $ret_json;
 }
Exemplo n.º 6
0
		/**
		 * Send email to new users
		 */
		public function triggerSendSignUpEmail($member_args)
		{
			$site_module_info = Context::get('site_module_info');
			$module_srl = $site_module_info->index_module_srl;

			$shop = new ShopInfo($module_srl);

			// Don't send anything if sender and receiver email addresses are missing
			if(!$shop->getEmail() || !$member_args->email_address)
			{
				ShopLogger::log("Failed to send welcome email to user. Member email is not set." . print_r($member_args, TRUE));
				return;
			}

			global $lang;
			$email_subject = sprintf($lang->new_member_email_subject
				, $shop->getShopTitle()
			);

			$email_content = sprintf($lang->new_member_email_content
				, getFullSiteUrl('', 'act', 'dispShopHome')
				, $shop->getShopTitle()
				, getFullSiteUrl('', 'act', 'dispShopMyAccount')
				, getFullSiteUrl('', 'act', 'dispShopHome')
				, $shop->getShopTitle()
			);

			$oMail = new Mail();
			$oMail->setTitle($email_subject);
			$oMail->setContent($email_content);
			$oMail->setSender($shop->getShopTitle(), $shop->getShopEmail());
			$oMail->setReceiptor(FALSE, $member_args->email_address);
			$oMail->send();
		}
Exemplo n.º 7
0
 /**
  * verify if product is available
  * @param bool $shopSettingsCheck
  * @return bool
  * @throws ShopException
  */
 public function isAvailable($shopSettingsCheck = true)
 {
     if (!$this->isPersisted()) {
         throw new ShopException('Product not persisted');
     }
     if ($shopSettingsCheck) {
         $shopInfo = new ShopInfo($this->module_srl);
         $shopSettingsCheck = $shopInfo->getOutOfStockProducts() == 'Y';
     }
     return $this->status != 'disabled' && (!$shopSettingsCheck || $shopSettingsCheck && $this->in_stock == 'Y');
 }
	/**
	 * Calls the Paypal API for executing the payment
	 *
	 * @param Cart $cart
	 * @param      $error_message
	 * @return bool|mixed
	 */
	public function processPayment(Cart $cart, &$error_message)
    {
        $payer_id = Context::get('payer_id');
        $token = Context::get('token');

        $paypalAPI = new PaypalExpressCheckoutAPI($this->gateway_api == PaypalExpressCheckout::LIVE_URL
			, $this->api_username
            , $this->api_password
            , $this->signature
        );

        // Get shop info
        $shop_info = new ShopInfo($cart->module_srl);

        // Prepare cart info
        $items = $this->getItemsFromCart($cart);

        $paypalAPI->doExpressCheckoutPayment($token
            , $payer_id
            , $items
            , ShopDisplay::numberFormat($cart->getItemTotal())
            , 0
            , ShopDisplay::numberFormat($cart->getShippingCost())
            , ShopDisplay::numberFormat($cart->getTotal())
            , $shop_info->getCurrency()
        );

        if(!$paypalAPI->success)
        {
            $error_message = $paypalAPI->error_message;
            return FALSE;
        }
        else
        {
            Context::set('payment_status', $paypalAPI->payment_status);
            return TRUE;
        }
    }
Exemplo n.º 9
0
 /**
  * Send email to user notifying him of the newly created order
  */
 public static function sendNewOrderEmails($order_srl)
 {
     $repo = new OrderRepository();
     $order = $repo->getOrderBySrl($order_srl);
     $shop = new ShopInfo($order->module_srl);
     // Don't send anything if shop email is not configured
     if (!$shop->getShopEmail()) {
         ShopLogger::log("Failed to send order email for order #{$order->order_srl}; Shop email is not configured");
         return;
     }
     self::sendNewOrderMailToCustomer($shop, $order);
     self::sendNewOrderMailToAdministrator($shop, $order);
 }
Exemplo n.º 10
0
 public function getUnitOfMeasure()
 {
     $shop = new ShopInfo($this->module_srl);
     return $shop->getUnitOfMeasure();
 }
        /**
         * init shop
         * @param $site_srl
         * @return Object
         */
        public function initShop($site_srl){
            $oCounterController = getController('counter');
            $oDocumentController = getController('document');
            $oCommentController = getController('comment');
            $oTagController = getController('tag');
            $oAddonController = getController('addon');
            $oEditorController = getController('editor');
            $oTrackbackController = getController('trackback');
            $oModuleModel = getModel('module');
            $oShopModel = getModel('shop');
            $oMemberModel = getModel('member');

            $site_info = $oModuleModel->getSiteInfo($site_srl);
            $module_srl = $site_info->index_module_srl;
            $args = new stdClass();
            $args->site_srl = $site_srl;

            $oShop = new ShopInfo($module_srl);
            if($oShop->module_srl != $module_srl) return new Object(-1,'msg_invalid_request');

            $oCounterController->deleteSiteCounterLogs($args->site_srl);
            $oAddonController->removeAddonConfig($args->site_srl);

            $args->module_srl = $module_srl;
            $output = executeQuery('shop.deleteShopFavorites', $args);
            $output = executeQuery('shop.deleteShopTags', $args);
            $output = executeQuery('shop.deleteShopVoteLogs', $args);
            $output = executeQuery('shop.deleteShopMemos', $args);
            $output = executeQuery('shop.deleteShopReferer', $args);
            $output = executeQuery('shop.deleteShopGuestbook', $args);
            $output = executeQuery('shop.deleteShopSupporters', $args);
            $output = executeQuery('shop.deletePublishLogs', $args);

            FileHandler::removeFile(sprintf("./files/cache/shop/shop_deny/%d.php",$module_srl));
            FileHandler::removeDir($oShopModel->getShopPath($module_srl));

            // delete document comment tag
            $output = $oDocumentController->triggerDeleteModuleDocuments($args);
            $output = $oCommentController->triggerDeleteModuleComments($args);
            $output = $oTagController->triggerDeleteModuleTags($args);
            $output = $oTrackbackController->triggerDeleteModuleTrackbacks($args);
            $args->module_srl = $args->module_srl *-1;

            $output = $oDocumentController->triggerDeleteModuleDocuments($args);
            $output = $oCommentController->triggerDeleteModuleComments($args);
            $output = $oTagController->triggerDeleteModuleTags($args);
            $args->module_srl = $args->module_srl *-1;

            // set category
            $obj = new stdClass();
            $obj->module_srl = $module_srl;
            $obj->title = Context::getLang('init_category_title');
            $oDocumentController->insertCategory($obj);

            FileHandler::copyDir($this->module_path.'skins/'.$this->skin, $oShopModel->getShopPath($module_srl));

            $langType = Context::getLangType();
            $file = sprintf('%ssample/%s.html',$this->module_path,$langType);
            if(!file_exists(FileHandler::getRealPath($file))){
                $file = sprintf('%ssample/ko.html',$this->module_path);
            }

            $member_info = $oMemberModel->getMemberInfoByEmailAddress($oShop->getUserId());
            $doc = new stdClass();
            $doc->module_srl = $module_srl;
            $doc->title = Context::getLang('sample_title');
            $doc->tags = Context::getLang('sample_tags');
            $doc->content = FileHandler::readFile($file);
            $doc->member_srl = $member_info->member_srl;
            $doc->user_id = $member_info->user_id;
            $doc->user_name = $member_info->user_name;
            $doc->nick_name = $member_info->nick_name;
            $doc->email_address = $member_info->email_address;
            $doc->homepage = $member_info->homepage;
            $output = $oDocumentController->insertDocument($doc, true);

            return new Object(1,'success_shop_init');
        }