コード例 #1
0
ファイル: ProductDetails.php プロジェクト: hungnv0789/vhtm
	/**
	 * Setup the purchasing options such as quantity box, stock messages,
	 * add to cart button, product fields etc.
	 */
	private function SetPurchasingOptions()
	{
		if(!$this->productClass->IsPurchasingAllowed()) {
			$GLOBALS['DisplayAdd'] = 'none';
			return;
		}

		$GLOBALS['AddToCartButton'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('ProductAddToCartButton');

		$GLOBALS['CartLink'] = CartLink();

		$GLOBALS['ProductCartQuantity'] = '';
		if(isset($GLOBALS['CartQuantity'.$this->productClass->GetProductId()])) {
			$GLOBALS['ProductCartQuantity'] = (int)$GLOBALS['CartQuantity'.$this->productClass->GetProductId()];
		}

		// If we're using a cart quantity drop down, load that
		if (GetConfig('TagCartQuantityBoxes') == 'dropdown') {
			if ($this->productClass->GetMinQty()) {
				$GLOBALS['Quantity' . $this->productClass->GetMinQty()] = 'selected="selected"';
			} else {
				$GLOBALS['Quantity1'] = 'selected="selected"';
			}
			$GLOBALS['QtyOptionZero'] = "";
			$GLOBALS['AddToCartQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemQtySelect");
		}
		// Otherwise, load the textbox
		else {
			$GLOBALS['ProductQuantity'] = 1;
			$GLOBALS['AddToCartQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemQtyText");
		}

		// Can we sell this product/option
		$saleable = IsProductSaleable($this->productClass->GetProduct());
		$variations = $this->productClass->GetProductVariationOptions();
		if(!empty($variations) && $this->productClass->GetProductInventoryTracking() == 2) {
			$productInStock = true;
		}
		else {
			$productInStock = $saleable;
		}

		if($productInStock == true) {
			$GLOBALS['SNIPPETS']['SideAddItemSoldOut'] = '';
			$GLOBALS['DisplayAdd'] = "";

			if (GetConfig('FastCartAction') == 'popup' && GetConfig('ShowCartSuggestions')) {
				$GLOBALS['FastCartButtonJs'] = ' && fastCartAction(event)';
			}
		}
		else if($this->productClass->IsPurchasingAllowed()) {
			$output = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideAddItemSoldOut");
			$output = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseSnippets($output, $GLOBALS['SNIPPETS']);
			$GLOBALS['SNIPPETS']['SideAddItemSoldOut'] = $output;

			$GLOBALS['BuyBoxSoldOut'] = "ProductBuyBoxSoldOut";
			$GLOBALS['DisplayAdd'] = "none";
			$GLOBALS['ISC_LANG']['BuyThisItem'] = GetLang('ItemUnavailable');
		}

		if(GetConfig('ShowAddToCartQtyBox') == 1) {
			$GLOBALS['DisplayAddQty'] = $GLOBALS['DisplayAdd'];
		}
		else {
			$GLOBALS['DisplayAddQty'] = "none";
		}

		if($this->productClass->IsPurchasingAllowed()) {
			$this->LoadEventDate();
			$this->LoadProductFieldsLayout();
		}

		$GLOBALS['ShowAddToCartQtyBox'] = GetConfig('ShowAddToCartQtyBox');
	}
コード例 #2
0
 /**
  * Load and set the options used for the "Add to Cart" functionality.
  *
  * @param string The position of the add to cart feature (either middle or side)
  */
 public function LoadAddToCartOptions($position = 'side')
 {
     $GLOBALS['ProductCartQuantity'] = '';
     if (isset($GLOBALS['CartQuantity' . $GLOBALS['ISC_CLASS_PRODUCT']->GetProductId()])) {
         $GLOBALS['ProductCartQuantity'] = (int) $GLOBALS['CartQuantity' . $GLOBALS['ISC_CLASS_PRODUCT']->GetProductId()];
     }
     if ($GLOBALS['ISC_CLASS_PRODUCT']->IsPurchasingAllowed()) {
         $GLOBALS['ProductPrice'] = $GLOBALS['ISC_CLASS_PRODUCT']->GetCalculatedPrice();
     }
     // If we're using a cart quantity drop down, load that
     if (GetConfig('TagCartQuantityBoxes') == 'dropdown') {
         $GLOBALS['Quantity1'] = "selected=\"selected\"";
         $GLOBALS['QtyOptionZero'] = "";
         $GLOBALS['AddToCartQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemQtySelect");
         // Otherwise, load the textbox
     } else {
         $GLOBALS['ProductQuantity'] = 1;
         $GLOBALS['AddToCartQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemQtyText");
     }
     $GLOBALS['UpdateCartQtyJs'] = '';
     // Are there any product variations?
     $prodVariations = $GLOBALS['ISC_CLASS_PRODUCT']->GetProductVariations();
     $GLOBALS['VariationList'] = '';
     $GLOBALS['SNIPPETS']['VariationList'] = '';
     $GLOBALS['HideVariationList'] = '';
     $GLOBALS['ProductOptionRequired'] = "false";
     // Can we sell this product/option
     $saleable = IsProductSaleable($GLOBALS['ISC_CLASS_PRODUCT']->GetProduct());
     if (!empty($prodVariations)) {
         // Is a product option required when adding the product to the cart?
         if ($GLOBALS['ISC_CLASS_PRODUCT']->IsOptionRequired()) {
             $GLOBALS['ProductOptionRequired'] = "true";
         }
         if (count($prodVariations) == 1 && count(current($prodVariations)) <= 5) {
             $onlyOneVariation = true;
             $GLOBALS['OptionMessage'] = GetLang('ChooseAnOption');
         } else {
             $GLOBALS['OptionMessage'] = GetLang('ChooseOneOrMoreOptions');
             $onlyOneVariation = false;
         }
         $ProductInStock = true;
         $useSelect = false;
         $GLOBALS['VariationNumber'] = 0;
         foreach ($prodVariations as $name => $options) {
             // If this is the only variation then instead of select boxes, just show radio buttons
             if ($position == 'middle') {
                 $GLOBALS['VariationChooseText'] = "";
             } else {
                 $GLOBALS['VariationChooseText'] = GetLang('ChooseA') . " " . isc_html_escape($name) . ":";
             }
             $GLOBALS['VariationNumber']++;
             $GLOBALS['SNIPPETS']['OptionList'] = '';
             if ($onlyOneVariation && count($options) <= 8 && !$GLOBALS['ISC_CLASS_PRODUCT']->IsOptionRequired()) {
                 $GLOBALS['OptionId'] = 0;
                 $GLOBALS['OptionValue'] = GetLang('zNone');
                 $GLOBALS['OptionChecked'] = "checked=\"checked\"";
                 $GLOBALS['SNIPPETS']['OptionList'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductVariationListSingleItem");
             } else {
                 if ($onlyOneVariation && count($options) > 8) {
                     $useSelect = true;
                 }
             }
             // Build the list of options
             $GLOBALS['OptionChecked'] = '';
             foreach ($options as $option) {
                 $GLOBALS['OptionId'] = (int) $option['voptionid'];
                 $GLOBALS['OptionValue'] = isc_html_escape($option['vovalue']);
                 if ($onlyOneVariation && !$useSelect) {
                     $GLOBALS['SNIPPETS']['OptionList'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductVariationListSingleItem");
                 } else {
                     if ($position == 'middle') {
                         $GLOBALS['VariationChooseText'] = GetLang('ChooseA') . " " . isc_html_escape($name) . ":";
                     }
                     $GLOBALS['SNIPPETS']['OptionList'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductVariationListMultipleItem");
                 }
             }
             $prefix = '';
             $suffix = '';
             if ($position == 'middle') {
                 $prefix = '<dt>' . isc_html_escape($name) . ':</dt><dd class="ProductOptionList">';
                 $suffix = '</dd>';
             }
             if ($onlyOneVariation == true && !$useSelect) {
                 $output = $prefix . $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductVariationListSingle") . $suffix;
             } else {
                 $GLOBALS['VariationChooseText'] = GetLang('ChooseA') . " " . isc_html_escape($name) . ":";
                 $output = $prefix . $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductVariationListMultiple") . $suffix;
             }
             $output = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseSnippets($output, $GLOBALS['SNIPPETS']);
             $GLOBALS['SNIPPETS']['VariationList'] .= $output;
         }
         if ($position != 'middle' && ($onlyOneVariation == false || $useSelect == true)) {
             $output = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ProductVariationMultiple");
             $output = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseSnippets($output, $GLOBALS['SNIPPETS']);
             $GLOBALS['SNIPPETS']['VariationList'] = $output;
         }
         $GLOBALS['ProductVariationJavascript'] = $GLOBALS['ISC_CLASS_PRODUCT']->GetProductVariationCombinationJavascript();
     } else {
         $GLOBALS['HideVariationList'] = 'display:none;';
         $ProductInStock = $saleable;
     }
     if ($ProductInStock == true) {
         $GLOBALS['SNIPPETS']['SideAddItemSoldOut'] = '';
         $GLOBALS['DisplayAdd'] = "";
     } else {
         $output = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("SideAddItemSoldOut");
         $output = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseSnippets($output, $GLOBALS['SNIPPETS']);
         $GLOBALS['SNIPPETS']['SideAddItemSoldOut'] = $output;
         $GLOBALS['BuyBoxSoldOut'] = "ProductBuyBoxSoldOut";
         $GLOBALS['DisplayAdd'] = "none";
         $GLOBALS['ISC_LANG']['BuyThisItem'] = GetLang('ItemUnavailable');
     }
     if (GetConfig('ShowAddToCartQtyBox') == 1) {
         $GLOBALS['DisplayAddQty'] = $GLOBALS['DisplayAdd'];
     } else {
         $GLOBALS['DisplayAddQty'] = "none";
     }
     ISC_SIDEPRODUCTADDTOCART_PANEL::LoadEventDate($position);
     ISC_SIDEPRODUCTADDTOCART_PANEL::LoadProductFieldsLayout($position);
     $GLOBALS['ShowAddToCartQtyBox'] = GetConfig('ShowAddToCartQtyBox');
 }