public function SetPanelSettings()
{
$GLOBALS['ISC_CLASS_CATEGORY'] = GetClass('ISC_CATEGORY');
// Should we hide the comparison button?
if(GetConfig('EnableProductComparisons') == 0 || $GLOBALS['ISC_CLASS_CATEGORY']->GetNumProducts() < 2) {
$GLOBALS['HideCompareItems'] = "none";
}
// Load the products into the reference array
$GLOBALS['ISC_CLASS_CATEGORY']->GetProducts($products);
$GLOBALS['CategoryProductListing'] = "";
if(GetConfig('ShowProductRating') == 0) {
$GLOBALS['HideProductRating'] = "display: none";
}
$display_mode = ucfirst(GetConfig("CategoryDisplayMode"));
if ($display_mode == "Grid") {
$display_mode = "";
}
$GLOBALS['DisplayMode'] = $display_mode;
if ($display_mode == "List") {
if (GetConfig('ShowAddToCartLink') && $GLOBALS['ISC_CLASS_CATEGORY']->GetNumProducts() > 0) {
$GLOBALS['HideAddButton'] = '';
} else {
$GLOBALS['HideAddButton'] = 'none';
}
$GLOBALS['ListJS'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ListCheckForm");
}
$GLOBALS['CompareButton'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CompareButton" . $display_mode);
if ($display_mode == "List" && $GLOBALS['ISC_CLASS_CATEGORY']->GetNumPages() > 1) {
$GLOBALS['CompareButtonTop'] = $GLOBALS['CompareButton'];
}
$GLOBALS['AlternateClass'] = '';
foreach($products as $row) {
$this->setProductGlobals($row);
// for list style
if ($display_mode == "List") {
// get a small chunk of the product description
$desc = isc_substr(strip_tags($row['proddesc']), 0, 225);
if (isc_strlen($row['proddesc']) > 225) {
// trim the description back to the last period or space so words aren't cut off
$period_pos = isc_strrpos($desc, ".");
$space_pos = isc_strrpos($desc, " ");
// find the character that we should trim back to. -1 on space pos for a space that follows a period, so we dont end up with 4 periods
if ($space_pos - 1 > $period_pos) {
$pos = $space_pos;
}
else {
$pos = $period_pos;
}
$desc = isc_substr($desc, 0, $pos);
$desc .= "...";
}
$GLOBALS['ProductDescription'] = $desc;
$GLOBALS['AddToCartQty'] = "";
if (CanAddToCart($row) && GetConfig('ShowAddToCartLink')) {
if (isId($row['prodvariationid']) || trim($row['prodconfigfields'])!='' || $row['prodeventdaterequired']) {
$GLOBALS['AddToCartQty'] = '<a href="' . $GLOBALS["ProductURL"] . '">' . $GLOBALS['ProductAddText'] . "</a>";
}
else {
$GLOBALS['CartItemId'] = $GLOBALS['ProductId'];
// If we're using a cart quantity drop down, load that
if (GetConfig('TagCartQuantityBoxes') == 'dropdown') {
$GLOBALS['Quantity0'] = "selected=\"selected\"";
$GLOBALS['QtyOptionZero'] = '<option %%GLOBAL_Quantity0%% value="0">Quantity</option>';
$GLOBALS['QtySelectStyle'] = 'width: auto;';
$GLOBALS['AddToCartQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemQtySelect");
// Otherwise, load the textbox
} else {
$GLOBALS['ProductQuantity'] = 0;
$GLOBALS['AddToCartQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemQtyText");
}
}
}
} // for grid style
else {
$GLOBALS["CompareOnSubmit"] = "onsubmit=\"return compareProducts(config.CompareLink)\"";
}
$GLOBALS['CategoryProductListing'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryProductsItem" . $display_mode);
}
if($GLOBALS['ISC_CLASS_CATEGORY']->GetNumProducts() == 0) {
// There are no products in this category
$GLOBALS['CategoryProductListing'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CategoryNoProductsMessage");
$GLOBALS['HideOtherProductsIn'] = 'none';
$GLOBALS['ExtraCategoryClass'] = "Wide WideWithLeft";
if($GLOBALS['SNIPPETS']['SubCategories'] != '') {
//.........这里部分代码省略.........
/**
* Generate a list of product fields for configurable products to be shown
* for a particular item in the cart based on the customer's configuration.
*
* @param array $productFields Array containing list of product fields for this product.
* @param int $cartItemId The ID of the item in the shopping cart.
*/
public function GetProductFieldDetails($productFields, $cartItemId)
{
// custom product fields on cart page
$GLOBALS['HideCartProductFields'] = 'display:none;';
$GLOBALS['CartProductFields'] = '';
if(isset($productFields) && !empty($productFields) && is_array($productFields)) {
$GLOBALS['HideCartProductFields'] = '';
foreach($productFields as $filedId => $field) {
switch ($field['type']) {
//field is a file
case 'file': {
//file is an image, display the image
$fieldValue = '<a target="_Blank" href="'.$GLOBALS['ShopPath'].'/viewfile.php?cartitem='.$cartItemId.'&prodfield='.$filedId.'">'.isc_html_escape($field['fileOriginalName']).'</a>';
break;
}
//field is a checkbox
case 'checkbox': {
$fieldValue = GetLang('Checked');
break;
}
//if field is a text area or short text display first
default: {
if(isc_strlen($field['value'])>50) {
$fieldValue = isc_substr(isc_html_escape($field['value']), 0, 50)." ..";
} else {
$fieldValue = isc_html_escape($field['value']);
}
}
}
if(trim($fieldValue) != '') {
$GLOBALS['CustomFieldName'] = isc_html_escape($field['name']);
$GLOBALS['CustomFieldValue'] = $fieldValue;
$GLOBALS['CartProductFields'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartProductFields");
}
}
}
}
/**
* Write an XML node element with raw value
*
* Method will write an XML node element WITHOUT encoding the value. PLEASE BE CAREFULL!!!
*
* @access protected
* @param string $name The XML node name
* @param string $value The XML node value
* @param int $maxLength The optional maximum length of the value. Default is 0 (unlimited)
* @return bool TRUE if the node was created, FALSE on error
*/
protected function writeRawElement($name, $value, $maxLength=0)
{
if (trim($name) == "") {
return false;
}
if ($maxLength > 0) {
$value = isc_substr($value, 0, $maxLength);
}
$this->xmlWriter->startElement($name);
$this->xmlWriter->writeRaw($value);
$this->xmlWriter->endElement();
return true;
}
public function buildXML()
{
if (isc_strtolower($this->spool["service"]) == "edit" && is_array($this->spoolReferenceData)) {
$this->writeEscapedElement("ListID", $this->spoolReferenceData["ListID"]);
$this->writeEscapedElement("EditSequence", $this->spoolReferenceData["EditSequence"]);
}
$this->buildProductVariationNameNode($this->spoolNodeData["prodname"], $this->spoolNodeData["combinationid"]);
$this->writeEscapedElement("IsActive", "true");
/**
* Set the product variation parent. Only do this for adding (want to edit the least amount as possible)
*/
if (isc_strtolower($this->spool["service"]) == "add") {
$productTypeListId = $this->accounting->getProductParentTypeListId(true);
if (!$productTypeListId || trim($productTypeListId) == '') {
throw new QBException("Unable to find product parent type reference for product variation in productvariation", $this->spool);
}
$this->xmlWriter->startElement("ParentRef");
$this->writeEscapedElement("ListID", $productTypeListId);
$this->xmlWriter->endElement();
}
if ($this->compareClientVersion("7.0") && isset($this->spoolNodeData["vcsku"]) && $this->spoolNodeData["vcsku"] !== "") {
$this->writeEscapedElement("ManufacturerPartNumber", $this->spoolNodeData["vcsku"]);
}
/**
* OK, different tag names for different versions for different countries. Good times, good times
*/
if ($this->compareClientCountry("uk") || $this->compareClientCountry("ca")) {
if ($this->compareClientVersion("3.0")) {
$this->xmlWriter->startElement("TaxCodeForSaleRef");
} else {
$this->xmlWriter->startElement("TaxCodeRef");
}
} else {
$this->xmlWriter->startElement("SalesTaxCodeRef");
}
$this->writeEscapedElement("FullName", "NON");
$this->xmlWriter->endElement();
$this->writeEscapedElement("SalesDesc", isc_substr($this->spoolNodeData["prodvariationname"], 0, 4095));
$prodPrice = CalcProductVariationPrice($this->spoolNodeData["prodprice"], $this->spoolNodeData["vcpricediff"], $this->spoolNodeData["vcprice"]);
$this->writeEscapedElement("SalesPrice", number_format($prodPrice, 2, ".", ""));
/**
* We can only set this for the add process as the mod process is only available in versions 7.0 and above
*/
if (isc_strtolower($this->spool["service"]) == "add" || $this->compareClientVersion("7.0")) {
$incomeAccountListId = $this->accounting->getAccountListId("income");
if (trim($incomeAccountListId) == '') {
throw new QBException("Cannot find the income account ListID for product variation ID: " . $this->spoolNodeData["combinationid"], $this->spool);
}
$this->xmlWriter->startElement("IncomeAccountRef");
$this->writeEscapedElement("ListID", $incomeAccountListId);
$this->xmlWriter->endElement();
}
if (isset($this->spoolNodeData["prodcostprice"]) && $this->spoolNodeData["prodcostprice"] > 0) {
$this->writeEscapedElement("PurchaseDesc", isc_substr($this->spoolNodeData["prodvariationname"], 0, 4095));
$this->writeEscapedElement("PurchaseCost", number_format($this->spoolNodeData["prodcostprice"], 2, ".", ""));
}
$cogsAccountListId = $this->accounting->getAccountListId("costofgoodssold");
if (trim($cogsAccountListId) == '') {
throw new QBException("Cannot find the cogs account ListID for product variation ID: " . $this->spoolNodeData["combinationid"], $this->spool);
}
$this->xmlWriter->startElement("COGSAccountRef");
$this->writeEscapedElement("ListID", $cogsAccountListId);
$this->xmlWriter->endElement();
$fixedAccountListId = $this->accounting->getAccountListId("fixedasset");
if (trim($fixedAccountListId) == '') {
throw new QBException("Cannot find the fixed account ListID for product ID: " . $this->spoolNodeData["combinationid"], $this->spool);
}
$this->xmlWriter->startElement("AssetAccountRef");
$this->writeEscapedElement("ListID", $fixedAccountListId);
$this->xmlWriter->endElement();
/**
* Only do this is we are a new product OR if we are handling the inventory levels
*/
if (isc_strtolower($this->spool["service"]) == "add" || $this->accounting->getValue("invlevels") == ACCOUNTING_QUICKBOOKS_TYPE_SHOPPINGCART) {
$this->writeEscapedElement("ReorderPoint", (int)$this->spoolNodeData["vclowstock"]);
}
if ($this->compareClientCountry("uk") && $this->compareClientVersion("2.0")) {
if (GetConfig("PricesIncludeTax")) {
$this->writeEscapedElement("AmountIncludesVAT", "1");
//.........这里部分代码省略.........
请发表评论