private function editOrderItemSearchAction() { if(empty($_REQUEST['q']) || empty($_REQUEST['quoteSession'])) { exit; } $quote = getClass('ISC_ADMIN_ORDERS')->getQuoteSession($_REQUEST['quoteSession']); if(!$quote) { exit; } $customerGroupId = $quote->getCustomerGroupId(); $_REQUEST['searchQuery'] = $_REQUEST['q']; // autocomplete plugin can send a limit which will be at most 11 but internally we limit this to 2-11 and // reduce it by 1 to get 1-10 and append the 'virtual' item result as #11 $limit = 11; if (isset($_REQUEST['limit'])) { $limit = max(2, min(10, (int)$_REQUEST['limit'])); } $limit--; $numProducts = 0; $result = getClass('ISC_ADMIN_PRODUCT')->_getProductList( 0, 'p.prodname', 'asc', $numProducts, 'DISTINCT p.*, '.GetProdCustomerGroupPriceSQL($customerGroupId), 10); $results = array(); while($product = $this->db->fetch($result)) { $isConfigurable = false; if($product['prodvariationid'] != 0 || $product['prodconfigfields'] != 0) { $isConfigurable = true; } $options = array( 'customerGroup' => $customerGroupId ); $price = calculateFinalProductPrice($product, $product['prodcalculatedprice'], $options); $price = formatPrice($price); $results[] = array( 'id' => $product['productid'], 'name' => $product['prodname'], 'link' => prodLink($product['prodname']), 'sku' => $product['prodcode'], 'isConfigurable' => $isConfigurable, 'price' => $price ); } $results[] = array( 'id' => 'virtual', 'virtualName' => $_REQUEST['q'], 'name' => GetLang('AddManualProduct'), 'className' => 'recordContentManual', 'price' => GetLang('AddManualProductHelp'), ); echo isc_json_encode($results); }
/** * Generate the body of the 'CartContent' panel, including the list of * products in the customer's shopping cart and the subtotal. */ public function generateCartContent() { if(!GetConfig('ShowThumbsInCart')) { $GLOBALS['HideThumbColumn'] = 'display: none'; $GLOBALS['ProductNameSpan'] = 2; } else { $GLOBALS['HideThumbColumn'] = ''; $GLOBALS['ProductNameSpan'] = 1; } $GLOBALS['SNIPPETS']['CartItems'] = ""; $items = $this->quote->getItems(); foreach($items as $item) { $name = $item->getName(); $quantity = $item->getQuantity(); $GLOBALS['CartItemId'] = $item->getId(); if($item instanceof ISC_QUOTE_ITEM_GIFTCERTIFICATE) { $GLOBALS['GiftCertificateName'] = isc_html_escape($name); $GLOBALS['GiftCertificateAmount'] = CurrencyConvertFormatPrice($item->getPrice()); $GLOBALS['GiftCertificateTo'] = isc_html_escape($item->getRecipientName()); $GLOBALS["Quantity" . $quantity] = 'selected="selected"'; $GLOBALS['ProductPrice'] = CurrencyConvertFormatPrice($item->getPrice()); $GLOBALS['ProductTotal'] = CurrencyConvertFormatPrice($item->getTotal()); $GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemGiftCertificate"); continue; } $GLOBALS['ProductName'] = isc_html_escape($name); $GLOBALS['ProductLink'] = prodLink($name); $GLOBALS['ProductAvailability'] = $item->getAvailability(); $GLOBALS['ItemId'] = $item->getProductId(); $GLOBALS['VariationId'] = $item->getVariationId(); $GLOBALS['ProductQuantity'] = $quantity; if(getConfig('ShowThumbsInCart')) { $GLOBALS['ProductImage'] = imageThumb($item->getThumbnail(), prodLink($name)); } $GLOBALS['UpdateCartQtyJs'] = "Cart.UpdateQuantity(this.options[this.selectedIndex].value);"; $GLOBALS['HideCartProductFields'] = 'display:none;'; $GLOBALS['CartProductFields'] = ''; $this->GetProductFieldDetails($item->getConfiguration(), $item->getId()); $GLOBALS['EventDate'] = ''; $eventDate = $item->getEventDate(true); if(!empty($eventDate)) { $GLOBALS['EventDate'] = ' <div style="font-style: italic; font-size:10px; color:gray">(' . $item->getEventName() . ': ' . isc_date('M jS Y', $eventDate) . ')</div>'; } $GLOBALS['GiftWrappingName'] = ''; $GLOBALS['HideGiftWrappingAdd'] = ''; $GLOBALS['HideGiftWrappingEdit'] = 'display: none'; $GLOBALS['HideGiftWrappingPrice'] = 'display: none'; $GLOBALS['GiftWrappingPrice'] = ''; $GLOBALS['GiftMessagePreview'] = ''; $GLOBALS['HideGiftMessagePreview'] = 'display: none'; $GLOBALS['HideWrappingOptions'] = 'display: none'; if($item->allowsGiftWrapping()) { $wrapping = $item->getGiftWrapping(); $GLOBALS['HideWrappingOptions'] = ''; if(!empty($wrapping)) { $GLOBALS['GiftWrappingName'] = isc_html_escape($wrapping['wrapname']); $GLOBALS['HideGiftWrappingAdd'] = 'display: none'; $GLOBALS['HideGiftWrappingEdit'] = ''; $GLOBALS['HideGiftWrappingPrice'] = ''; $GLOBALS['GiftWrappingPrice'] = CurrencyConvertFormatPrice($wrapping['wrapprice']); if(!empty($wrapping['wrapmessage'])) { if(isc_strlen($wrapping['wrapmessage']) > 30) { $wrapping['wrapmessage'] = substr($wrapping['wrapmessage'], 0, 27).'...'; } $GLOBALS['GiftMessagePreview'] = isc_html_escape($wrapping['wrapmessage']); $GLOBALS['HideGiftMessagePreview'] = ''; } } else { $GLOBALS['HideGiftWrappingAdd'] = ''; } } $price = $item->getPrice($this->displayIncludingTax); $total = $item->getTotal($this->displayIncludingTax); $GLOBALS['ProductPrice'] = currencyConvertFormatPrice($price); $GLOBALS['ProductTotal'] = currencyConvertFormatPrice($total); // Don't allow the quantity of free items/parent restricted items to be changed $GLOBALS['HideCartItemRemove'] = ''; if($item->getParentId()) { $GLOBALS['CartItemQty'] = number_format($item->getQuantity()); $GLOBALS['HideCartItemRemove'] = 'display: none'; } // If we're using a cart quantity drop down, load that else if (GetConfig('TagCartQuantityBoxes') == 'dropdown') { $GLOBALS["Quantity" . $quantity] = "selected=\"selected\""; if($quantity == 0) { $GLOBALS['QtyOptionZero'] = "<option ".$GLOBALS["Quantity0"]." value='0'>0</option>"; } else { $GLOBALS['QtyOptionZero'] = "<option value='0'>0</option>"; } // Fixes products being displayed with '0' quantity when the quantity is greater than 30 (hard coded limit in snippet) if ($quantity > 30) { $GLOBALS["QtyOptionSelected"] = "<option ".$GLOBALS["Quantity" . $quantity]." value='" . $quantity . "'>" . $quantity . "</option>"; } $GLOBALS['CartItemQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemQtySelect"); } // Otherwise, load the textbox else { $GLOBALS['CartItemQty'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItemQtyText"); } // Is this product a variation? $GLOBALS['ProductOptions'] = ''; $options = $item->getVariationOptions(); if(!empty($options)) { $GLOBALS['ProductOptions'] .= "<br /><small>("; $comma = ''; foreach($options as $name => $value) { if(!trim($name) || !trim($value)) { continue; } $GLOBALS['ProductOptions'] .= $comma.isc_html_escape($name).": ".isc_html_escape($value); $comma = ', '; } $GLOBALS['ProductOptions'] .= ")</small>"; } $GLOBALS['HideExpectedReleaseDate'] = 'display: none;'; if($item->isPreOrder()) { $GLOBALS['ProductExpectedReleaseDate'] = $item->getPreOrderMessage(); $GLOBALS['HideExpectedReleaseDate'] = ''; } $GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CartItem"); $GLOBALS["Quantity" . $quantity] = ""; } $GLOBALS['CartItemTotal'] = currencyConvertFormatPrice($this->quote->getSubTotal($this->displayIncludingTax)); $GLOBALS['CartTotal'] = currencyConvertFormatPrice($this->quote->getGrandTotal()); if($this->quote->getWrappingCost() > 0) { $GLOBALS['GiftWrappingTotal'] = currencyConvertFormatPrice($this->quote->getWrappingCost()); } else { $GLOBALS['HideGiftWrappingTotal'] = 'display: none'; } $script = " $('.quantityInput').live('change', function() { Cart.UpdateQuantity($(this).val()); }); "; $GLOBALS['ISC_CLASS_TEMPLATE']->clientScript->registerScript($script,'ready'); }
/** * Build the contents for the order confirmation page. This function sets up everything to be used by * the order confirmation on the express checkout page as well as the ConfirmOrder page when using a * multi step checkout. */ public function BuildOrderConfirmation() { $GLOBALS['ISC_CLASS_CUSTOMER'] = GetClass('ISC_CUSTOMER'); if(!GetConfig('ShowMailingListInvite')) { $GLOBALS['HideMailingListInvite'] = 'none'; } // Do we need to show the special offers & discounts checkbox and should they // either of the newsletter checkboxes be ticked by default? if (GetConfig('MailAutomaticallyTickNewsletterBox')) { $GLOBALS['NewsletterBoxIsTicked'] = 'checked="checked"'; } if (ISC_EMAILINTEGRATION::doOrderAddRulesExist()) { if (GetConfig('MailAutomaticallyTickOrderBox')) { $GLOBALS['OrderBoxIsTicked'] = 'checked="checked"'; } } else { $GLOBALS['HideOrderCheckBox'] = "none"; } if(isset($_REQUEST['ordercomments'])) { $GLOBALS['OrderComments'] = $_REQUEST['ordercomments']; } // Now we check if we have an incoming coupon or gift certificate code to apply if (isset($_REQUEST['couponcode']) && $_REQUEST['couponcode'] != '') { $code = trim($_REQUEST['couponcode']); // Were we passed a gift certificate code? if (self::isCertificateCode($code)) { try { $this->getQuote()->applyGiftCertificate($code); // If successful show a message $GLOBALS['CheckoutSuccessMsg'] = GetLang('GiftCertificateAppliedToCart'); } catch(ISC_QUOTE_EXCEPTION $e) { $GLOBALS['CheckoutErrorMsg'] = $e->getMessage(); } } // Otherwise, it must be a coupon code else { try { $this->getQuote()->applyCoupon($code); // Coupon code applied successfully $GLOBALS['CheckoutSuccessMsg'] = GetLang('CouponAppliedToCart'); } catch(ISC_QUOTE_EXCEPTION $e) { $GLOBALS['CheckoutErrorMsg'] = $e->getMessage(); } } } $GLOBALS['ISC_CLASS_ACCOUNT'] = GetClass('ISC_ACCOUNT'); // Determine what we'll be showing for the redeem gift certificate/coupon code box if (gzte11(ISC_LARGEPRINT)) { $GLOBALS['RedeemTitle'] = GetLang('RedeemGiftCertificateOrCoupon'); $GLOBALS['RedeemIntro'] = GetLang('RedeemGiftCertificateorCouponIntro'); } else { $GLOBALS['RedeemTitle'] = GetLang('RedeemCouponCode'); $GLOBALS['RedeemIntro'] = GetLang('RedeemCouponCodeIntro'); } $GLOBALS['HideCheckoutError'] = "none"; $GLOBALS['HidePaymentOptions'] = ""; $GLOBALS['HideUseCoupon'] = ''; $checkoutProviders = array(); // if the provider list html is set in session then use it as the payment provider options. // it's normally set in payment modules when it's required. if(isset($_SESSION['CHECKOUT']['ProviderListHTML'])) { $GLOBALS['HidePaymentProviderList'] = ""; $GLOBALS['HidePaymentOptions'] = ""; $GLOBALS['PaymentProviders'] = $_SESSION['CHECKOUT']['ProviderListHTML']; $GLOBALS['StoreCreditPaymentProviders'] = $_SESSION['CHECKOUT']['ProviderListHTML']; $GLOBALS['CheckoutWith'] = ""; } else { // Get a list of checkout providers $checkoutProviders = GetCheckoutModulesThatCustomerHasAccessTo(true); // If no checkout providers are set up, send an email to the store owner and show an error message if (empty($checkoutProviders)) { $GLOBALS['HideConfirmOrderPage'] = "none"; $GLOBALS['HideCheckoutError'] = ''; $GLOBALS['HideTopPaymentButton'] = "none"; $GLOBALS['HidePaymentProviderList'] = "none"; $GLOBALS['CheckoutErrorMsg'] = GetLang('NoCheckoutProviders'); $GLOBALS['NoCheckoutProvidersError'] = sprintf(GetLang("NoCheckoutProvidersErrorLong"), $GLOBALS['ShopPath']); $GLOBALS['EmailHeader'] = GetLang("NoCheckoutProvidersSubject"); $GLOBALS['EmailMessage'] = sprintf(GetLang("NoCheckoutProvidersErrorLong"), $GLOBALS['ShopPath']); $emailTemplate = FetchEmailTemplateParser(); $emailTemplate->SetTemplate("general_email"); $message = $emailTemplate->ParseTemplate(true); require_once(ISC_BASE_PATH . "/lib/email.php"); $obj_email = GetEmailClass(); $obj_email->Set('CharSet', GetConfig('CharacterSet')); $obj_email->From(GetConfig('OrderEmail'), GetConfig('StoreName')); $obj_email->Set("Subject", GetLang("NoCheckoutProvidersSubject")); $obj_email->AddBody("html", $message); $obj_email->AddRecipient(GetConfig('AdminEmail'), "", "h"); $email_result = $obj_email->Send(); } // We have more than one payment provider, hide the top button and build a list else if (count($checkoutProviders) > 1) { $GLOBALS['HideTopPaymentButton'] = "none"; $GLOBALS['HideCheckoutError'] = "none"; } // There's only one payment provider - hide the list else { $GLOBALS['HidePaymentProviderList'] = "none"; $GLOBALS['HideCheckoutError'] = "none"; $GLOBALS['HidePaymentOptions'] = "none"; list(,$provider) = each($checkoutProviders); if(method_exists($provider['object'], 'ShowPaymentForm') && !isset($_SESSION['CHECKOUT']['ProviderListHTML'])) { $GLOBALS['ExpressCheckoutLoadPaymentForm'] = 'ExpressCheckout.ShowSingleMethodPaymentForm();'; } if ($provider['object']->GetPaymentType() == PAYMENT_PROVIDER_OFFLINE) { $GLOBALS['PaymentButtonSwitch'] = "ShowContinueButton();"; } $GLOBALS['CheckoutWith'] = $provider['object']->GetDisplayName(); } // Build the list of payment provider options $GLOBALS['PaymentProviders'] = $GLOBALS['StoreCreditPaymentProviders'] = ""; foreach ($checkoutProviders as $provider) { $GLOBALS['ProviderChecked'] = ''; if(count($checkoutProviders) == 1) { $GLOBALS['ProviderChecked'] = 'checked="checked"'; } $GLOBALS['ProviderId'] = $provider['object']->GetId(); $GLOBALS['ProviderName'] = isc_html_escape($provider['object']->GetDisplayName()); $GLOBALS['ProviderType'] = $provider['object']->GetPaymentType("text"); if(method_exists($provider['object'], 'ShowPaymentForm')) { $GLOBALS['ProviderPaymentFormClass'] = 'ProviderHasPaymentForm'; } else { $GLOBALS['ProviderPaymentFormClass'] = ''; } $GLOBALS['PaymentFieldPrefix'] = ''; $GLOBALS['PaymentProviders'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CheckoutProviderOption"); $GLOBALS['PaymentFieldPrefix'] = 'credit_'; $GLOBALS['StoreCreditPaymentProviders'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CheckoutProviderOption"); } } // Are we coming back to this page for a particular reason? if (isset($_SESSION['REDIRECT_TO_CONFIRMATION_MSG'])) { $GLOBALS['HideCheckoutError'] = ''; $GLOBALS['CheckoutErrorMsg'] = $_SESSION['REDIRECT_TO_CONFIRMATION_MSG']; unset($_SESSION['REDIRECT_TO_CONFIRMATION_MSG']); } $displayIncludingTax = false; if(getConfig('taxDefaultTaxDisplayCart') != TAX_PRICES_DISPLAY_EXCLUSIVE) { $displayIncludingTax = true; } $items = $this->getQuote()->getItems(); // Start building the summary of all of the items in the order $GLOBALS['SNIPPETS']['CartItems'] = ''; foreach ($items as $item) { $GLOBALS['ProductQuantity'] = $item->getQuantity(); $price = $item->getPrice($displayIncludingTax); $total = $item->getTotal($displayIncludingTax); $GLOBALS['ProductPrice'] = currencyConvertFormatPrice($price); $GLOBALS['ProductTotal'] = currencyConvertFormatPrice($total); if($item instanceof ISC_QUOTE_ITEM_GIFTCERTIFICATE) { $GLOBALS['GiftCertificateName'] = isc_html_escape($item->getName()); $GLOBALS['GiftCertificateTo'] = isc_html_escape($item->getRecipientName()); $GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CheckoutCartItemGiftCertificate"); continue; } $GLOBALS['ProductAvailability'] = $item->getAvailability(); $GLOBALS['ItemId'] = $item->getProductId(); // Is this product a variation? $GLOBALS['ProductOptions'] = ''; $options = $item->getVariationOptions(); if(!empty($options)) { $GLOBALS['ProductOptions'] .= "<br /><small>("; $comma = ''; foreach($options as $name => $value) { if(!trim($name) || !trim($value)) { continue; } $GLOBALS['ProductOptions'] .= $comma.isc_html_escape($name).": ".isc_html_escape($value); $comma = ', '; } $GLOBALS['ProductOptions'] .= ")</small>"; } $GLOBALS['EventDate'] = ''; $eventDate = $item->getEventDate(true); if(!empty($eventDate)) { $GLOBALS['EventDate'] = ' <div style="font-style: italic; font-size:10px; color:gray">(' . $item->getEventName() . ': ' . isc_date('M jS Y', $eventDate) . ')</div>'; } $GLOBALS['HideGiftWrapping'] = 'display: none'; $GLOBALS['GiftWrappingName'] = ''; $GLOBALS['GiftMessagePreview'] = ''; $GLOBALS['HideGiftMessagePreview'] = 'display: none'; $wrapping = $item->getGiftWrapping(); if($wrapping !== false) { $GLOBALS['HideGiftWrapping'] = ''; $GLOBALS['GiftWrappingName'] = isc_html_escape($wrapping['wrapname']); if(!empty($wrapping['wrapmessage'])) { if(isc_strlen($wrapping['wrapmessage']) > 30) { $wrapping['wrapmessage'] = substr($wrapping['wrapmessage'], 0, 27).'...'; } $GLOBALS['GiftMessagePreview'] = isc_html_escape($wrapping['wrapmessage']); $GLOBALS['HideGiftMessagePreview'] = ''; } } //create configurable product fields on order confirmation page with the data posted from add to cart page $GLOBALS['CartProductFields'] = ''; $configuration = $item->getConfiguration(); if (!empty($configuration)) { require_once ISC_BASE_PATH.'/includes/display/CartContent.php'; ISC_CARTCONTENT_PANEL::GetProductFieldDetails($configuration, $item->getId()); } $GLOBALS['ProductName'] = isc_html_escape($item->getName()); $GLOBALS['ProductImage'] = imageThumb($item->getThumbnail(), prodLink($item->getName())); $GLOBALS['HideExpectedReleaseDate'] = 'display: none;'; if($item->isPreOrder()) { $GLOBALS['ProductExpectedReleaseDate'] = $item->getPreOrderMessage(); $GLOBALS['HideExpectedReleaseDate'] = ''; } $GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CheckoutCartItem"); } // Do we have a shipping price to show? if(!$this->getQuote()->isDigital()) { $shippingAddresses = $this->getQuote()->getShippingAddresses(); $numShippingAddresses = count($shippingAddresses); if($numShippingAddresses == 1) { $shippingAddress = $this->getQuote()->getShippingAddress(); $GLOBALS['ShippingAddress'] = $GLOBALS['ISC_CLASS_ACCOUNT']->FormatShippingAddress($shippingAddress->getAsArray()); } else { $GLOBALS['ShippingAddress'] = '<em>(Order will be shipped to multiple addresses)</em>'; } // Show the shipping details $GLOBALS['HideShippingDetails'] = ''; } // This is a digital order - no shipping applies else { $GLOBALS['HideShippingDetails'] = 'display: none'; $GLOBALS['HideShoppingCartShippingCost'] = 'none'; $GLOBALS['ShippingAddress'] = GetLang('NotRequiredForDigitalDownloads'); $GLOBALS['ShippingMethod'] = GetLang('ShippingImmediateDownload'); } $billingAddress = $this->getQuote()->getBillingAddress(); $GLOBALS['BillingAddress'] = getClass('ISC_ACCOUNT') ->formatShippingAddress($billingAddress->getAsArray()); $totalRows = self::getQuoteTotalRows($this->getQuote()); $templateTotalRows = ''; foreach($totalRows as $id => $totalRow) { $GLOBALS['ISC_CLASS_TEMPLATE']->assign('label', $totalRow['label']); $GLOBALS['ISC_CLASS_TEMPLATE']->assign('classNameAppend', ucfirst($id)); $value = currencyConvertFormatPrice($totalRow['value']); $GLOBALS['ISC_CLASS_TEMPLATE']->assign('value', $value); $templateTotalRows .= $GLOBALS['ISC_CLASS_TEMPLATE']->getSnippet('CheckoutCartTotal'); } $GLOBALS['ISC_CLASS_TEMPLATE']->assign('totals', $templateTotalRows); $grandTotal = $this->getQuote()->getGrandTotal(); $GLOBALS['GrandTotal'] = formatPrice($grandTotal); if($grandTotal == 0) { $GLOBALS['HidePaymentOptions'] = "none"; $GLOBALS['HideUseCoupon'] = 'none'; $GLOBALS['HidePaymentProviderList'] = "none"; $GLOBALS['PaymentButtonSwitch'] = "ShowContinueButton(); ExpressCheckout.UncheckPaymentProvider();"; } // Does the customer have any store credit they can use? $GLOBALS['HideUseStoreCredit'] = "none"; $GLOBALS['HideRemainingStoreCredit'] = "none"; $customer = $GLOBALS['ISC_CLASS_CUSTOMER']->GetCustomerDataByToken(); if ($customer['custstorecredit'] > 0) { $GLOBALS['HidePaymentOptions'] = ""; $GLOBALS['StoreCredit'] = CurrencyConvertFormatPrice($customer['custstorecredit']); $GLOBALS['HideUseStoreCredit'] = ""; $GLOBALS['HidePaymentProviderList'] = "none"; // The customer has enough store credit to pay for the entirity of this order if ($customer['custstorecredit'] >= $grandTotal) { $GLOBALS['PaymentButtonSwitch'] = "ShowContinueButton();"; $GLOBALS['HideLimitedCreditWarning'] = "none"; $GLOBALS['HideLimitedCreditPaymentOption'] = "none"; $GLOBALS['HideCreditPaymentMethods'] = "none"; $GLOBALS['RemainingCredit'] = $customer['custstorecredit'] - $grandTotal; if ($GLOBALS['RemainingCredit'] > 0) { $GLOBALS['HideRemainingStoreCredit'] = ''; $GLOBALS['RemainingCredit'] = CurrencyConvertFormatPrice($GLOBALS['RemainingCredit']); } } // Customer doesn't have enough store credit to pay for the order else { $GLOBALS['Remaining'] = CurrencyConvertFormatPrice($grandTotal-$customer['custstorecredit']); if(count($checkoutProviders) == 1) { $GLOBALS['CheckoutStoreCreditWarning'] = sprintf(GetLang('CheckoutStoreCreditWarning2'), $GLOBALS['Remaining'], $GLOBALS['CheckoutWith']); $GLOBALS['HideLimitedCreditPaymentOption'] = "none"; } else { $GLOBALS['CheckoutStoreCreditWarning'] = GetLang('CheckoutStoreCreditWarning'); } $GLOBALS['ISC_LANG']['CreditPaymentMethod'] = sprintf(GetLang('CreditPaymentMethod'), $GLOBALS['Remaining']); } if (count($checkoutProviders) > 1) { $GLOBALS['CreditAlt'] = GetLang('CheckoutCreditAlt'); } else if (count($checkoutProviders) <= 1 && isset($GLOBALS['CheckoutWith'])) { $GLOBALS['CreditAlt'] = sprintf(GetLang('CheckoutCreditAltOneMethod'), $GLOBALS['CheckoutWith']); } else { if ($customer['custstorecredit'] >= $grandTotal) { $GLOBALS['HideCreditAltOptionList'] = "none"; $GLOBALS['HideConfirmOrderPage'] = ""; $GLOBALS['HideTopPaymentButton'] = "none"; $GLOBALS['HideCheckoutError'] = "none"; $GLOBALS['CheckoutErrorMsg'] = ''; } } } // Customer has hit this page before. Delete the existing pending order // The reason we do a delete is if they're hitting this page again, something // has changed with their order or something has become invalid with it along the way. if (isset($_COOKIE['SHOP_ORDER_TOKEN']) && IsValidPendingOrderToken($_COOKIE['SHOP_ORDER_TOKEN'])) { $query = " SELECT orderid FROM [|PREFIX|]orders WHERE ordtoken='".$GLOBALS['ISC_CLASS_DB']->Quote($_COOKIE['SHOP_ORDER_TOKEN'])."' AND ordstatus=0 "; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while($order = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $entity = new ISC_ENTITY_ORDER(); /** @todo ISC-1141 check to see if this needs changing to ->purge() */ /** @todo ISC-860 this is relying on another bugfix, I'm leaving this as ->delete() for now so that orders remain in the db somewhere at least -gwilym */ if ($entity->delete($order['orderid'], true)) { $GLOBALS['ISC_CLASS_LOG']->LogSystemNotice('general', GetLang('OrderDeletedAutomatically', array('order' => $order['orderid']))); } } } // Are we showing an error message? if (isset($GLOBALS['CheckoutErrorMsg']) && $GLOBALS['CheckoutErrorMsg'] != '') { $GLOBALS['HideCheckoutError'] = ''; } else { $GLOBALS['HideCheckoutError'] = "none"; } // Is there a success message to show? if (isset($GLOBALS['CheckoutSuccessMsg']) && $GLOBALS['CheckoutSuccessMsg'] != '') { $GLOBALS['HideCheckoutSuccess'] = ''; } else { $GLOBALS['HideCheckoutSuccess'] = "none"; } if(GetConfig('EnableOrderComments') == 1) { $GLOBALS['HideOrderComments'] = ""; } else { $GLOBALS['HideOrderComments'] = "none"; } if(GetConfig('EnableOrderTermsAndConditions') == 1) { $GLOBALS['HideOrderTermsAndConditions'] = ""; if(GetConfig('OrderTermsAndConditionsType') == "link") { $GLOBALS['AgreeTermsAndConditions'] = GetLang('YesIAgree'); $GLOBALS['TermsAndConditionsLink'] = "<a href='".GetConfig('OrderTermsAndConditionsLink')."' target='_BLANK'>".strtolower(GetLang('TermsAndConditions'))."</a>."; $GLOBALS['HideTermsAndConditionsTextarea'] = "display:none;"; } else { $GLOBALS['HideTermsAndConditionsTextarea']= ''; $GLOBALS['OrderTermsAndConditions'] = GetConfig('OrderTermsAndConditions'); $GLOBALS['AgreeTermsAndConditions'] = GetLang('AgreeTermsAndConditions'); $GLOBALS['TermsAndConditionsLink'] = ''; } } else { $GLOBALS['HideOrderTermsAndConditions'] = "display:none;"; } // BCSIXBETA-372 - mail format preferences removed/disabled for now // %%SNIPPET_CheckoutMailFormatPreference%% references also need to be added back into the checkout panels/snippets to re-enable this if needed // $GLOBALS['MailFormatPreferenceOptions'] = $this->GenerateMailFormatPreferenceOptions(); // $GLOBALS['SNIPPETS']['CheckoutMailFormatPreference'] = $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet('CheckoutMailFormatPreference'); }
public function CopyProductStep1($MsgDesc = "", $MsgStatus = "", $PreservePost=false, $OriginalProductID=0) { if ($MsgDesc != "") { $GLOBALS['Message'] = MessageBox($MsgDesc, $MsgStatus); } // Show the form to edit a product if (isset($_REQUEST['productId']) && isId($_REQUEST['productId'])) { $OriginalProductID = $_REQUEST['productId']; } $prodId = $OriginalProductID; $z = 0; $arrData = array(); $arrCustomFields = array(); if (GetConfig('CurrencyLocation') == 'right') { $GLOBALS['CurrencyTokenLeft'] = ''; $GLOBALS['CurrencyTokenRight'] = GetConfig('CurrencyToken'); } else { $GLOBALS['CurrencyTokenLeft'] = GetConfig('CurrencyToken'); $GLOBALS['CurrencyTokenRight'] = ''; } $GLOBALS['ServerFiles'] = $this->_GetImportFilesOptions(); $GLOBALS['ISC_CLASS_ADMIN_CATEGORY'] = GetClass('ISC_ADMIN_CATEGORY'); // Make sure the product exists if (ProductExists($prodId)) { if($PreservePost == true) { $this->_GetProductData(0, $arrData); $this->_GetCustomFieldData(0, $arrCustomFields); $GLOBALS['ProductFields'] = $this->_GetProductFieldsLayout(0, true); // Restore the hash $GLOBALS['ProductHash'] = $arrData['prodhash']; } else { $this->_GetProductData($prodId, $arrData); $this->_GetCustomFieldData($prodId, $arrCustomFields); $GLOBALS['ProductFields'] = $this->_GetProductFieldsLayout($prodId, true); // Generate the hash $GLOBALS['ProductHash'] = md5(time().uniqid(rand(), true)); // We'll need to duplicate (copy) the thumbnail, images and download files here $this->_CopyDownloads($prodId, 0, $GLOBALS['ProductHash']); $productImages = ISC_PRODUCT_IMAGE::copyImagesToProductHash($prodId, $GLOBALS['ProductHash']); $this->setupProductImageGlobals($productImages); $arrData['prodname'] = GetLang('CopyOf') . $arrData['prodname']; } $this->template->assign('product', $arrData); // Does this user have permission to edit this product? if($GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId() && $arrData['prodvendorid'] != $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId()) { FlashMessage(GetLang('Unauthorized'), MSG_ERROR, 'index.php?ToDo=viewProducts'); } if(isset($_POST['currentTab'])) { $GLOBALS['CurrentTab'] = (int)$_POST['currentTab']; } else { $GLOBALS['CurrentTab'] = 0; } $GLOBALS['FormAction'] = 'copyProduct2'; $GLOBALS['Title'] = GetLang('CopyProductTitle'); $GLOBALS['Intro'] = GetLang('CopyProductIntro'); $GLOBALS["ProdType_" . $arrData['prodtype']] = 'checked="checked"'; $GLOBALS['ProdType'] = $arrData['prodtype'] - 1; $GLOBALS['ProdCode'] = isc_html_escape($arrData['prodcode']); $GLOBALS['ProdName'] = isc_html_escape($arrData['prodname']); $GLOBALS['OriginalProductId'] = $OriginalProductID; $visibleCategories = array(); if($GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId()) { $vendorData = $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendor(); if($vendorData['vendoraccesscats']) { $visibleCategories = explode(',', $vendorData['vendoraccesscats']); } } $GLOBALS['CategoryOptions'] = $GLOBALS['ISC_CLASS_ADMIN_CATEGORY']->GetCategoryOptions($arrData['prodcats'], "<option %s value='%d'>%s</option>", "selected='selected'", "", false, '', $visibleCategories); $GLOBALS['RelatedCategoryOptions'] = $GLOBALS['ISC_CLASS_ADMIN_CATEGORY']->GetCategoryOptions(0, "<option %s value='%d'>%s</option>", "selected='selected'", "- ", false); $wysiwygOptions = array( 'id' => 'wysiwyg', 'width' => '100%', 'height' => '500px', 'value' => $arrData['proddesc'] ); $GLOBALS['WYSIWYG'] = GetClass('ISC_ADMIN_EDITOR')->GetWysiwygEditor($wysiwygOptions); $GLOBALS['ProdSearchKeywords'] = isc_html_escape($arrData['prodsearchkeywords']); $GLOBALS['ProdAvailability'] = isc_html_escape($arrData['prodavailability']); $GLOBALS['ProdPrice'] = number_format($arrData['prodprice'], GetConfig('DecimalPlaces'), GetConfig('DecimalToken'), ""); if (CFloat($arrData['prodcostprice']) > 0) { $GLOBALS['ProdCostPrice'] = number_format($arrData['prodcostprice'], GetConfig('DecimalPlaces'), GetConfig('DecimalToken'), ""); } if (CFloat($arrData['prodretailprice']) > 0) { $GLOBALS['ProdRetailPrice'] = number_format($arrData['prodretailprice'], GetConfig('DecimalPlaces'), GetConfig('DecimalToken'), ""); } if (CFloat($arrData['prodsaleprice']) > 0) { $GLOBALS['ProdSalePrice'] = number_format($arrData['prodsaleprice'], GetConfig('DecimalPlaces'), GetConfig('DecimalToken'), ""); } $GLOBALS['ProdSortOrder'] = $arrData['prodsortorder']; if ($arrData['prodvisible'] == 1) { $GLOBALS['ProdVisible'] = "checked"; } if ($arrData['prodfeatured'] == 1) { $GLOBALS['ProdFeatured'] = "checked"; } if($GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId()) { $GLOBALS['HideStoreFeatured'] = 'display: none'; } else if(!gzte11(ISC_HUGEPRINT) || !$arrData['prodvendorid']) { $GLOBALS['HideVendorFeatured'] = 'display: none'; } if($arrData['prodvendorfeatured'] == 1) { $GLOBALS['ProdVendorFeatured'] = 'checked="checked"'; } if($arrData['prodallowpurchases'] == 1) { $GLOBALS['ProdAllowPurchases'] = 'checked="checked"'; } else { if($arrData['prodhideprice'] == 1) { $GLOBALS['ProdHidePrice'] = 'checked="checked"'; } $GLOBALS['ProdCallForPricingLabel'] = isc_html_escape($arrData['prodcallforpricinglabel']); } $GLOBALS['ProdWarranty'] = $arrData['prodwarranty']; $GLOBALS['ProdWeight'] = number_format($arrData['prodweight'], GetConfig('DecimalPlaces'), GetConfig('DecimalToken'), ""); if (CFloat($arrData['prodwidth']) > 0) { $GLOBALS['ProdWidth'] = number_format($arrData['prodwidth'], GetConfig('DecimalPlaces'), GetConfig('DecimalToken'), ""); } if (CFloat($arrData['prodheight']) > 0) { $GLOBALS['ProdHeight'] = number_format($arrData['prodheight'], GetConfig('DecimalPlaces'), GetConfig('DecimalToken'), ""); } if (CFloat($arrData['proddepth']) > 0) { $GLOBALS['ProdDepth'] = number_format($arrData['proddepth'], GetConfig('DecimalPlaces'), GetConfig('DecimalToken'), ""); } if (CFloat($arrData['prodfixedshippingcost']) > 0) { $GLOBALS['ProdFixedShippingCost'] = number_format($arrData['prodfixedshippingcost'], GetConfig('DecimalPlaces'), GetConfig('DecimalToken'), ""); } if ($arrData['prodfreeshipping'] == 1) { $GLOBALS['FreeShipping'] = 'checked="checked"'; } if($arrData['prodrelatedproducts'] == -1) { $GLOBALS['IsProdRelatedAuto'] = 'checked="checked"'; } else if(isset($arrData['prodrelated'])) { $GLOBALS['RelatedProductOptions'] = ""; foreach ($arrData['prodrelated'] as $r) { $GLOBALS['RelatedProductOptions'] .= sprintf("<option value='%d'>%s</option>", (int) $r[0], isc_html_escape($r[1])); } } $GLOBALS['ProdTags'] = $arrData['prodtags']; $GLOBALS['CurrentStockLevel'] = $arrData['prodcurrentinv']; $GLOBALS['LowStockLevel'] = $arrData['prodlowinv']; $GLOBALS["InvTrack_" . $arrData['prodinvtrack']] = 'checked="checked"'; $GLOBALS['WrappingOptions'] = $this->BuildGiftWrappingSelect(explode(',', $arrData['prodwrapoptions'])); $GLOBALS['HideGiftWrappingOptions'] = 'display: none'; if($arrData['prodwrapoptions'] == 0) { $GLOBALS['WrappingOptionsDefaultChecked'] = 'checked="checked"'; } else if($arrData['prodwrapoptions'] == -1) { $GLOBALS['WrappingOptionsNoneChecked'] = 'checked="checked"'; } else { $GLOBALS['HideGiftWrappingOptions'] = ''; $GLOBALS['WrappingOptionsCustomChecked'] = 'checked="checked"'; } if ($arrData['prodinvtrack'] == 1) { $GLOBALS['OptionButtons'] = "ToggleProductInventoryOptions(true);"; } else { $GLOBALS['OptionButtons'] = "ToggleProductInventoryOptions(false);"; } if ($arrData['prodoptionsrequired'] == 1) { $GLOBALS['OptionsRequired'] = 'checked="checked"'; } if ($arrData['prodtype'] == 1) { $GLOBALS['HideProductInventoryOptions'] = "none"; } $GLOBALS['EnterOptionPrice'] = sprintf(GetLang('EnterOptionPrice'), GetConfig('CurrencyToken'), GetConfig('CurrencyToken')); $GLOBALS['EnterOptionWeight'] = sprintf(GetLang('EnterOptionWeight'), GetConfig('WeightMeasurement')); $GLOBALS['HideCustomFieldLink'] = "none"; if(getConfig('taxEnteredWithPrices') == TAX_PRICES_ENTERED_INCLUSIVE) { $this->template->assign('enterPricesWithTax', true); } $GLOBALS['CustomFields'] = ''; $GLOBALS['CustomFieldKey'] = 0; if (!empty($arrCustomFields)) { foreach ($arrCustomFields as $f) { $GLOBALS['CustomFieldName'] = isc_html_escape($f['name']); $GLOBALS['CustomFieldValue'] = isc_html_escape($f['value']); $GLOBALS['CustomFieldLabel'] = $this->GetFieldLabel(($GLOBALS['CustomFieldKey']+1), GetLang('CustomField')); if (!$GLOBALS['CustomFieldKey']) { $GLOBALS['HideCustomFieldDelete'] = 'none'; } else { $GLOBALS['HideCustomFieldDelete'] = ''; } $GLOBALS['CustomFields'] .= $this->template->render('Snippets/CustomFields.html'); $GLOBALS['CustomFieldKey']++; } } // Add one more custom field $GLOBALS['CustomFieldName'] = ''; $GLOBALS['CustomFieldValue'] = ''; $GLOBALS['CustomFieldLabel'] = $this->GetFieldLabel(($GLOBALS['CustomFieldKey']+1), GetLang('CustomField')); if (!$GLOBALS['CustomFieldKey']) { $GLOBALS['HideCustomFieldDelete'] = 'none'; } else { $GLOBALS['HideCustomFieldDelete'] = ''; } $GLOBALS['CustomFields'] .= $this->template->render('Snippets/CustomFields.html'); // Get a list of any downloads associated with this product $GLOBALS['DownloadsGrid'] = $this->GetDownloadsGrid(0, $GLOBALS['ProductHash']); $GLOBALS['ISC_LANG']['MaxUploadSize'] = sprintf(GetLang('MaxUploadSize'), GetMaxUploadSize()); if($GLOBALS['DownloadsGrid'] == '') { $GLOBALS['DisplayDownloaadGrid'] = "none"; } // Get the brands as select options $GLOBALS['ISC_CLASS_ADMIN_BRANDS'] = GetClass('ISC_ADMIN_BRANDS'); $GLOBALS['BrandNameOptions'] = $GLOBALS['ISC_CLASS_ADMIN_BRANDS']->GetBrandsAsOptions($arrData['prodbrandid']); $GLOBALS['SaveAndAddAnother'] = GetLang('SaveAndAddAnother'); // Get a list of all layout files $layoutFile = 'product.html'; if($arrData['prodlayoutfile'] != '') { $layoutFile = $arrData['prodlayoutfile']; } $GLOBALS['LayoutFiles'] = GetCustomLayoutFilesAsOptions("product.html", $layoutFile); $GLOBALS['ProdPageTitle'] = isc_html_escape($arrData['prodpagetitle']); $GLOBALS['ProdMetaKeywords'] = isc_html_escape($arrData['prodmetakeywords']); $GLOBALS['ProdMetaDesc'] = isc_html_escape($arrData['prodmetadesc']); $GLOBALS['SaveAndAddAnother'] = GetLang('SaveAndAddAnother'); if(!gzte11(ISC_MEDIUMPRINT)) { $GLOBALS['HideInventoryOptions'] = "none"; } else { $GLOBALS['HideInventoryOptions'] = ''; } // Does this product have a variation assigned to it? $GLOBALS['ProductVariationExisting'] = $arrData['prodvariationid']; if($arrData['prodvariationid'] > 0) { $GLOBALS['IsYesVariation'] = 'checked="checked"'; } else { $GLOBALS['IsNoVariation'] = 'checked="checked"'; $GLOBALS['HideVariationList'] = "none"; $GLOBALS['HideVariationCombinationList'] = "none"; } // Get the list of tax classes and assign them $this->template->assign('taxClasses', array( 0 => getLang('DefaultTaxClass') ) + getClass('ISC_TAX')->getTaxClasses()); // If there are no variations then disable the option to choose one $numVariations = 0; $GLOBALS['VariationOptions'] = $this->GetVariationsAsOptions($numVariations, $arrData['prodvariationid']); if($numVariations == 0) { $GLOBALS['VariationDisabled'] = "DISABLED"; $GLOBALS['VariationColor'] = "#CACACA"; $GLOBALS['IsNoVariation'] = 'checked="checked"'; $GLOBALS['IsYesVariation'] = ""; $GLOBALS['HideVariationCombinationList'] = "none"; } else { // Load the variation combinations if($arrData['prodinvtrack'] == 2) { $show_inv_fields = true; } else { $show_inv_fields = false; } /** * We'll need to duplicate the variation combinations here if we are NOT preserving the post */ if (!$PreservePost) { $this->_CopyVariationData($arrData['productid'], 0, $GLOBALS['ProductHash']); } $GLOBALS['VariationCombinationList'] = $this->_LoadVariationCombinationsTable($arrData['prodvariationid'], $show_inv_fields, 0, $GLOBALS['ProductHash']); } if(!gzte11(ISC_HUGEPRINT)) { $GLOBALS['HideVendorOption'] = 'display: none'; } else { $vendorData = $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendor(); if(isset($vendorData['vendorid'])) { $GLOBALS['HideVendorSelect'] = 'display: none'; $GLOBALS['CurrentVendor'] = isc_html_escape($vendorData['vendorname']); } else { $GLOBALS['HideVendorLabel'] = 'display: none'; $GLOBALS['VendorList'] = $this->BuildVendorSelect($arrData['prodvendorid']); } } // Display the discount rules if ($PreservePost == true) { $GLOBALS['DiscountRules'] = $this->GetDiscountRules(0); } else { $GLOBALS['DiscountRules'] = $this->GetDiscountRules($prodId); } // Hide if we are not enabled if (!GetConfig('BulkDiscountEnabled')) { $GLOBALS['HideDiscountRulesWarningBox'] = ''; $GLOBALS['DiscountRulesWarningText'] = GetLang('DiscountRulesNotEnabledWarning'); $GLOBALS['DiscountRulesWithWarning'] = 'none'; // Also hide it if this product has variations } else if (isset($arrData['prodvariationid']) && isId($arrData['prodvariationid'])) { $GLOBALS['HideDiscountRulesWarningBox'] = ''; $GLOBALS['DiscountRulesWarningText'] = GetLang('DiscountRulesVariationWarning'); $GLOBALS['DiscountRulesWithWarning'] = 'none'; } else { $GLOBALS['HideDiscountRulesWarningBox'] = 'none'; $GLOBALS['DiscountRulesWithWarning'] = ''; } $GLOBALS['DiscountRulesEnabled'] = (int)GetConfig('BulkDiscountEnabled'); $GLOBALS['EventDateFieldName'] = $arrData['prodeventdatefieldname']; if ($GLOBALS['EventDateFieldName'] == null) { $GLOBALS['EventDateFieldName'] = GetLang('EventDateDefault'); } if ($arrData['prodeventdaterequired'] == 1) { $GLOBALS['EventDateRequired'] = 'checked="checked"'; $from_stamp = $arrData['prodeventdatelimitedstartdate']; $to_stamp = $arrData['prodeventdatelimitedenddate']; } else { $from_stamp = isc_gmmktime(0, 0, 0, isc_date("m"), isc_date("d"), isc_date("Y")); $to_stamp = isc_gmmktime(0, 0, 0, isc_date("m")+1, isc_date("d"), isc_date("Y")); } if ($arrData['prodeventdatelimited'] == 1) { $GLOBALS['LimitDates'] = 'checked="checked"'; } $GLOBALS['LimitDateOption1'] = ''; $GLOBALS['LimitDateOption2'] = ''; $GLOBALS['LimitDateOption3'] = ''; switch ($arrData['prodeventdatelimitedtype']) { case 1 : $GLOBALS['LimitDateOption1'] = 'selected="selected"'; break; case 2 : $GLOBALS['LimitDateOption2'] = 'selected="selected"'; break; case 3 : $GLOBALS['LimitDateOption3'] = 'selected="selected"'; break; } // Set the global variables for the select boxes $from_day = isc_date("d", $from_stamp); $from_month = isc_date("m", $from_stamp); $from_year = isc_date("Y", $from_stamp); $to_day = isc_date("d", $to_stamp); $to_month = isc_date("m", $to_stamp); $to_year = isc_date("Y", $to_stamp); $GLOBALS['OverviewFromDays'] = $this->_GetDayOptions($from_day); $GLOBALS['OverviewFromMonths'] = $this->_GetMonthOptions($from_month); $GLOBALS['OverviewFromYears'] = $this->_GetYearOptions($from_year); $GLOBALS['OverviewToDays'] = $this->_GetDayOptions($to_day); $GLOBALS['OverviewToMonths'] = $this->_GetMonthOptions($to_month); $GLOBALS['OverviewToYears'] = $this->_GetYearOptions($to_year); if(!$GLOBALS['ISC_CLASS_ADMIN_AUTH']->HasPermission(AUTH_Create_Category)) { $GLOBALS['HideCategoryCreation'] = 'display: none'; } //Google website optimizer $GLOBALS['HideOptimizerConfigForm'] = 'display:none;'; $GLOBALS['CheckEnableOptimizer'] = ''; $GLOBALS['SkipConfirmMsg'] = 'false'; $GLOBALS['GoogleWebsiteOptimizerIntro'] = GetLang('ProdGoogleWebsiteOptimizerIntro'); $enabledOptimizers = GetConfig('OptimizerMethods'); if(!empty($enabledOptimizers)) { foreach ($enabledOptimizers as $id => $date) { GetModuleById('optimizer', $optimizerModule, $id); if ($optimizerModule->_testPage == 'products' || $optimizerModule->_testPage == 'all') { $GLOBALS['SkipConfirmMsg'] = 'false'; break; } } } if($arrData['product_enable_optimizer'] == '1') { $GLOBALS['HideOptimizerConfigForm'] = ''; $GLOBALS['CheckEnableOptimizer'] = 'Checked'; } $this->template->assign('prodminqty', $arrData['prodminqty']); $this->template->assign('prodmaxqty', $arrData['prodmaxqty']); $optimizer = getClass('ISC_ADMIN_OPTIMIZER'); $GLOBALS['OptimizerConfigForm'] = $optimizer->showPerItemConfigForm('product', $arrData['productid'],prodLink($arrData['prodname'])); if ($arrData['prodpreorder'] && $arrData['prodreleasedateremove'] && time() >= $arrData['prodreleasedate']) { // pre-order release date has passed and remove is ticked, remove it now for the copy form at least - saving it will commit it to the db $arrData['prodpreorder'] = 0; $arrData['prodreleasedate'] = 0; $arrData['prodreleasedateremove'] = 0; } // note: prodpreorder is a database column does not map directly to a form field, it'll be set to 1 if _prodorderable is 'pre', along with prodallowpurchases to 1 // note: _prodorderable is a form field that does not map to a database column if (!$arrData['prodallowpurchases']) { $this->template->assign('_prodorderable', 'no'); } else if ($arrData['prodpreorder']) { $this->template->assign('_prodorderable', 'pre'); } else { $this->template->assign('_prodorderable', 'yes'); } $this->template->assign('prodreleasedateremove', $arrData['prodreleasedateremove']); if (isset($arrData['prodpreordermessage']) && $arrData['prodpreordermessage']) { $this->template->assign('prodpreordermessage', $arrData['prodpreordermessage']); } else { $this->template->assign('prodpreordermessage', GetConfig('DefaultPreOrderMessage')); } if ($arrData['prodreleasedate']) { $this->template->assign('prodreleasedate', isc_date('d/m/Y', $arrData['prodreleasedate'])); } $GLOBALS['ProdCondition' . $arrData['prodcondition'] . 'Selected'] = 'selected="selected"'; if ($arrData['prodshowcondition']) { $GLOBALS['ProdShowCondition'] = 'checked="checked"'; } // Open Graph Settings $this->template->assign('openGraphTypes', ISC_OPENGRAPH::getObjectTypes(true)); $this->template->assign('openGraphSelectedType', $arrData['opengraph_type']); $this->template->assign('openGraphUseProductName', (bool)$arrData['opengraph_use_product_name']); $this->template->assign('openGraphTitle', $arrData['opengraph_title']); $this->template->assign('openGraphUseMetaDescription', (bool)$arrData['opengraph_use_meta_description']); $this->template->assign('openGraphDescription', $arrData['opengraph_description']); $this->template->assign('openGraphUseImage', (bool)$arrData['opengraph_use_image']); // UPC $this->template->assign('ProdUPC', $arrData['upc']); // Google Checkout $this->template->assign('ProdDisableGoogleCheckout', $arrData['disable_google_checkout']); $GLOBALS['SaveAndAddAnother'] = GetLang('SaveAndAddAnother'); $this->setupProductLanguageString(); $this->template->display('product.form.tpl'); } else { // The product doesn't exist if ($GLOBALS["ISC_CLASS_ADMIN_AUTH"]->HasPermission(AUTH_Manage_Products)) { $this->ManageProducts(GetLang('ProductDoesntExist'), MSG_ERROR); } else { $GLOBALS['ISC_CLASS_ADMIN_ENGINE']->DoHomePage(GetLang('Unauthorized'), MSG_ERROR); } } }
/** * Display the quick view for an order * * @return void **/ public function GetOrderQuickView() { $this->engine->loadLangFile('orders'); if(empty($_REQUEST['o'])) { exit; } $orderId = (int)$_REQUEST['o']; // Get the details for this order from the database $query = " SELECT o.*, CONCAT(custconfirstname, ' ', custconlastname) AS custname, custconemail, custconphone, (SELECT COUNT(messageid) FROM [|PREFIX|]order_messages WHERE messageorderid=orderid AND messagestatus='unread') AS numunreadmessages FROM [|PREFIX|]orders o LEFT JOIN [|PREFIX|]customers c ON (c.customerid=o.ordcustid) WHERE o.orderid='".$GLOBALS['ISC_CLASS_DB']->Quote($orderId)."' "; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); $order = $GLOBALS['ISC_CLASS_DB']->Fetch($result); $orderStatuses = array(); $query = " SELECT * FROM [|PREFIX|]order_status ORDER BY statusorder ASC "; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while($status = $GLOBALS['ISC_CLASS_DB']->fetch($result)) { $orderStatuses[$status['statusid']] = $status['statusdesc']; } $this->template->assign('orderStatuses', $orderStatuses); // Order wasn't found if(!$order) { echo getLang('OrderDetailsNotFound'); exit; } // If this user is a vendor, do they have permission to acess this order? else if($GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId() && $row['ordvendorid'] != $GLOBALS['ISC_CLASS_ADMIN_AUTH']->GetVendorId()) { echo getLang('OrderDetailsNotFound'); exit; } $addressTypes = array( 'billingAddress' => 'ordbill', ); // Build the address fields foreach($addressTypes as $var => $dbKey) { $address = array( 'firstname' => $order[$dbKey.'firstname'], 'lastname' => $order[$dbKey.'lastname'], 'company' => $order[$dbKey.'company'], 'address1' => $order[$dbKey.'street1'], 'address2' => $order[$dbKey.'street2'], 'city' => $order[$dbKey.'suburb'], 'state' => $order[$dbKey.'state'], 'zip' => $order[$dbKey.'zip'], 'country' => $order[$dbKey.'country'] ); if($order[$dbKey.'countrycode'] && file_exists(ISC_BASE_PATH.'/lib/flags/'.strtolower($order[$dbKey.'countrycode']).'.gif')) { $address['countryFlag'] = strtolower($order[$dbKey.'countrycode']); } $this->template->assign($var, $address); } $itemTotalColumn = 'total_ex_tax'; $shippingCostColumn = 'cost_ex_tax'; if(getConfig('taxDefaultTaxDisplayOrders') == TAX_PRICES_DISPLAY_INCLUSIVE) { $itemTotalColumn = 'total_inc_tax'; $shippingCostColumn = 'cost_inc_tax'; } // Does the payment method have any extra info to show? $provider = null; if(GetModuleById('checkout', $provider, $order['orderpaymentmodule'])) { if(method_exists($provider, "DisplayPaymentDetails")) { $this->template->assign('orderExtraInfo', $provider->DisplayPaymentDetails($order)); } } if($order['extrainfo']) { $extraArray = unserialize($order['extrainfo']); if(!empty($extraArray['payment_message'])) { $order['payment_message'] = $extraArray['payment_message']; } } // Fetch all of the addresses in this order $orderAddresses = array(); $query = " SELECT * FROM [|PREFIX|]order_addresses WHERE order_id='".$order['orderid']."' "; $result = $this->db->query($query); while($address = $this->db->fetch($result)) { if($address['country_iso2'] && file_exists(ISC_BASE_PATH.'/lib/flags/'.strtolower($address['country_iso2']).'.gif')) { $address['countryFlag'] = strtolower($address['country_iso2']); } $orderAddresses[$address['id']] = array( 'address' => $address, 'shipping' => array(), 'products' => array(), ); // Grab any custom form fields if($address['form_session_id']) { $orderAddresses[$address['id']]['customFields'] = $GLOBALS['ISC_CLASS_FORM']->getSavedSessionData( $address['form_session_id'], array(), FORMFIELDS_FORM_SHIPPING, true ); } } // Fetch the shipping details for this order $query = " SELECT * FROM [|PREFIX|]order_shipping WHERE order_id='".$order['orderid']."' "; $result = $this->db->query($query); while($shipping = $this->db->fetch($result)) { $shipping['cost'] = $shipping[$shippingCostColumn]; $orderAddresses[$shipping['order_address_id']]['shipping'] = $shipping; } // Get the products in the order $prodFieldsArray = getClass('ISC_ADMIN_ORDERS')->getOrderProductFieldsData($orderId); // Get the products in the order $products = array(); $query = " SELECT o.*, p.productid, p.prodname, p.prodpreorder, p.prodreleasedate, p.prodpreordermessage FROM [|PREFIX|]order_products o LEFT JOIN [|PREFIX|]products p ON (p.productid=o.ordprodid) WHERE orderorderid='" . $orderId . "' ORDER BY ordprodname"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while($product = $this->db->fetch($result)) { if($product['ordprodoptions'] != '') { $product['options'] = unserialize($product['ordprodoptions']); } if(isset($prodFieldsArray[$product['orderprodid']])) { $product['configurable_fields'] = $prodFieldsArray[$product['orderprodid']]; } if($product['prodname']) { $product['prodlink'] = prodLink($product['prodname']); } if($product['productid'] && $product['prodpreorder']) { $message = getLang('Thisisapreordereditem'); if($product['prodreleasedate']) { $message = $product['prodpreordermessage']; if(!$message) { $message = getConfig('DefaultPreOrderMessage'); } $message = str_replace('%%DATE%%', isc_date(getConfig('DisplayDateFormat'), $product['prodreleasedate']), $message); } $product['preorder_message'] = $message; } if($product['ordprodeventdate']) { $product['ordprodeventdate'] = isc_date('jS M Y', $product['ordprodeventdate']); } $product['total'] = $product[$itemTotalColumn]; $productAddressId = $product['order_address_id']; if(!isset($orderAddresses[$productAddressId])) { $orderAddresses[$productAddressId] = array( 'products' => array() ); } $orderAddresses[$productAddressId]['products'][] = $product; } $this->template->assign('orderAddresses', $orderAddresses); $this->template->assign('totalRows', getOrderTotalRows($order)); if (gzte11(ISC_MEDIUMPRINT) && isId($order['ordformsessionid'])) { $billingFields = $GLOBALS['ISC_CLASS_FORM']->getSavedSessionData( $order['ordformsessionid'], array(), FORMFIELDS_FORM_BILLING, true ); $this->template->assign('billingCustomFields', $billingFields); $shippingFields = $GLOBALS['ISC_CLASS_FORM']->getSavedSessionData( $order['ordformsessionid'], array(), FORMFIELDS_FORM_SHIPPING, true ); $this->template->assign('shippingCustomFields', $shippingFields); } $this->template->assign('order', $order); $this->template->assign('orderStatusOptions', getClass('ISC_ADMIN_ORDERS')->getOrderStatusOptions($order['ordstatus']) ); $message = ''; $flashMessages = GetFlashMessages(); if(is_array($flashMessages)) { foreach($flashMessages as $flashMessage) { $message .= MessageBox($flashMessage['message'], $flashMessage['type']); } } $this->template->assign('message', $message); $this->template->display('order.quickview.tpl'); }
private function _BuildProductFeed($feedTitle, $feedDescription, $feedId, $sortField, $sortOrder, $searchTerms=array()) { $this->_SetFeedDetails(); $feed = new ISC_FEED_GENERATOR($feedId, $this->_type, (int)GetConfig('RSSCacheTime')*60); $channel = array( "title" => $feedTitle, "description" => $feedDescription, "link" => $GLOBALS['ShopPath'], 'namespaces' => array( 'isc' => array( //'http://dtd.interspire.com/rss/isc-1.0.dtd', '', array( 'store_title' => getConfig('StoreName') ) ) ) ); $feed->SetChannel($channel); // The magical Unreal Shopping Cart RSS feeds are actually just custom searches so pipe it off to our search function $searchterms = BuildProductSearchTerms($searchTerms); $searchQueries = BuildProductSearchQuery($searchterms, '', $sortField, $sortOrder); // Run the query $searchQueries['query'] .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, (int)GetConfig('RSSItemsLimit')); $result = $GLOBALS['ISC_CLASS_DB']->Query($searchQueries['query']); while($product = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { if(isc_strlen($product['proddesc']) > 300) { $product['proddesc'] = isc_substr($product['proddesc'], 0, 298).".."; } $item = array( 'title' => $product['prodname'], 'date' => $product['proddateadded'], 'link' => prodLink($product['prodname']), 'namespaces' => array( 'isc' => array( 'description' => $product['proddesc'], 'productid' => $product['productid'], ) ) ); if($product['imagefile']) { $thumb = ImageThumb($product, ProdLink($product['prodname'])); $product['proddesc'] = sprintf("<div style='float: right; padding: 10px;'>%s</div>%s", $thumb, $product['proddesc']); $image = new ISC_PRODUCT_IMAGE; $image->populateFromDatabaseRow($product); try { $item['namespaces']['isc']['thumb'] = $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL, true); } catch (Exception $exception) { } try { $item['namespaces']['isc']['image'] = $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_ZOOM, true); } catch (Exception $exception) { } unset ($image); } // Determine the price of this product $price = ''; if (GetConfig('ShowProductPrice') && !$product['prodhideprice']) { $calcPrice = $product['prodcalculatedprice']; $plainPrice = formatProductPrice($product, $calcPrice, array( 'strikeRetail' => false, 'displayInclusive' => getConfig('taxDefaultTaxDisplayCatalog') )); if($plainPrice) { $item['namespaces']['isc']['price'] = $plainPrice; $price = '<strong>'.getLang('Price').': '.$plainPrice.'</strong>'; } } if(GetConfig('ShowProductRating')) { $ratingImage = $GLOBALS['IMG_PATH'].'/IcoRating'.(int)$product['prodavgrating'].'.gif'; $item['namespaces']['isc']['rating'] = (int)$product['prodavgrating']; $item['namespaces']['isc']['rating_image'] = $ratingImage; $ratingImage = '<img src="'.$ratingImage.'" alt="" />'; } else { $ratingImage = ''; } $product['proddesc'] .= '<p>'.$price.' '.$ratingImage.'</p>'; $item['description'] = $product['proddesc']; $feed->AddItem($item); } // Send the feed to the browser $feed->OutputFeed(); }
private function _setupFastCartData($quote, $item) { // product info $name = $item->getName(); $prodLink = '<a href="'.prodLink($name).'">'.$name.'</a>'; $prodImg = imageThumb($item->getThumbnail(), prodLink($name)); $prodTotal = CurrencyConvertFormatPrice($item->getTotal()); // x item(s) has/have been added $quantity = $item->getQuantity(); $quantityTxt = GetLang('OneItemAdded'); if ($quantity > 1) { $quantityTxt = GetLang('XItemsAdded', array('count' => $quantity)); } // your cart contains x item(s) $numItems = $quote->getNumItems(); $numItemsTxt = GetLang('OneItem'); if ($numItems > 1) { $numItemsTxt = GetLang('XItems', array('count' => $numItems)); } // variation? $options = $item->getVariationOptions(); if(!empty($options)) { $holder = array(); foreach($options as $name => $value) { if(!trim($name) || !trim($value)) { continue; } $holder[] = isc_html_escape($name).': '.isc_html_escape($value); } $prodLink .= ' <small>('.implode(', ', $holder).')</small>'; } // setup suggestive content $GLOBALS['HideSuggestiveCartContent'] = 'display:none'; if (GetConfig('ShowCartSuggestions')) { $GLOBALS['HideSuggestiveCartContent'] = ''; $GLOBALS['SuggestiveCartContentLimit'] = 4; $GLOBALS['ISC_CLASS_TEMPLATE']->GetPanelContent('SuggestiveCartContent'); } // setup buttons ob_start(); $this->showRegularCart(); ob_end_clean(); $GLOBALS['fastCartProdImg'] = $prodImg; $GLOBALS['fastCartProdLink'] = $prodLink; $GLOBALS['fastCartProdTotal'] = $prodTotal; $GLOBALS['fastCartQuantity'] = $quantity; $GLOBALS['fastCartQuantityTxt'] = $quantityTxt; $GLOBALS['fastCartNumItemsTxt'] = $numItemsTxt; $GLOBALS['fastCartSubtotal'] = CurrencyConvertFormatPrice($quote->getSubTotal()); }