/** * 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'); }
/** * 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() { 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"'; } // Is Interspire Email Marketer integrated? if (GetConfig('MailXMLAPIValid') && GetConfig('UseMailerForOrders') && GetConfig('MailOrderList') > 0) { // Yes, should we tick the speical offers & discounts checkbox by default? 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 (isc_strlen($code) == GIFT_CERTIFICATE_LENGTH && gzte11(ISC_LARGEPRINT)) { $cart = GetClass('ISC_CART'); if ($cart->api->ApplyGiftCertificate($code)) { // If successful show a message $GLOBALS['CheckoutSuccessMsg'] = GetLang('GiftCertificateAppliedToCart'); } else { $GLOBALS['CheckoutErrorMsg'] = implode('<br />', $cart->api->GetErrors()); } } else { $cart = GetClass('ISC_CART'); if ($cart->api->ApplyCoupon($code)) { $this->api->ReapplyCouponsFromCart(); //Added by Simha temp fix to avoid having multiple times coupon for same item $GLOBALS['ISC_CLASS_CART']->api->UpdateCartInformation(); // Coupon code applied successfully $GLOBALS['CheckoutSuccessMsg'] = GetLang('CouponAppliedToCart'); } else { $GLOBALS['CheckoutErrorMsg'] = implode('<br />', $cart->api->GetErrors()); } } } $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'] = ''; // 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(); } else { if (count($checkoutProviders) > 1) { $GLOBALS['HideTopPaymentButton'] = "none"; $GLOBALS['HideCheckoutError'] = "none"; } 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']); } // Get a summary of the order $orderSummary = $this->CalculateOrderSummary(); // Start building the summary of all of the items in the order $GLOBALS['SNIPPETS']['CartItems'] = ''; foreach ($orderSummary['products'] as $cartKey => $product) { $GLOBALS['ProductQuantity'] = $product['quantity']; $GLOBALS['ProductPrice'] = CurrencyConvertFormatPrice($product['price']); $GLOBALS['ProductTotal'] = CurrencyConvertFormatPrice($product['total']); // If the item in the cart is a gift certificate, we need to show a special type of row if (isset($product['type']) && $product['type'] == "giftcertificate") { $GLOBALS['GiftCertificateName'] = isc_html_escape($product['data']['prodname']); $GLOBALS['GiftCertificateTo'] = isc_html_escape($product['certificate']['to_name']); $GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CheckoutCartItemGiftCertificate"); } else { $GLOBALS['ProductAvailability'] = isc_html_escape($product['data']['prodavailability']); $GLOBALS['ItemId'] = $product['data']['productid']; // If this is a discounted price (from a coupon) override the product price to the was/now version if (isset($product['discount_price']) && $product['discount_price'] != $product['original_price']) { $GLOBALS['ProductPrice'] = sprintf("<s class='CartStrike'>%s</s> %s", CurrencyConvertFormatPrice($product['original_price']), CurrencyConvertFormatPrice($product['price'])); } // Is this product a variation? $GLOBALS['ProductOptions'] = ''; if (isset($product['options']) && !empty($product['options'])) { $GLOBALS['ProductOptions'] .= "<br /><small>("; $comma = ''; foreach ($product['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'] = ''; if (isset($product['event_date'])) { $GLOBALS['EventDate'] = '<div style="font-style: italic; font-size:11px; padding-left:10px">' . $product['event_name'] . ': ' . isc_date('M jS Y', $product['event_date']) . '</div>'; } $GLOBALS['HideGiftWrapping'] = 'display: none'; $GLOBALS['HideGiftMessagePreview'] = 'display: none'; $GLOBALS['GiftWrappingName'] = ''; $GLOBALS['GiftMessagePreview'] = ''; if (isset($product['wrapping_name'])) { $GLOBALS['HideGiftWrapping'] = ''; $GLOBALS['GiftWrappingName'] = isc_html_escape($product['wrapping_name']); if (isset($product['wrapping_message'])) { if (isc_strlen($product['wrapping_message']) > 30) { $product['wrapping_message'] = substr($product['wrapping_message'], 0, 27) . '...'; } $GLOBALS['GiftMessagePreview'] = isc_html_escape($product['wrapping_message']); if ($product['wrapping_message']) { $GLOBALS['HideGiftMessagePreview'] = ''; } } } //create configurable product fields on order confirmation page with the data posted from add to cart page $GLOBALS['CartProductFields'] = ''; if (isset($product['productFields'])) { require_once ISC_BASE_PATH . '/includes/display/CartContent.php'; ISC_CARTCONTENT_PANEL::GetProductFieldDetails($product['productFields'], $cartKey); } $GLOBALS['ProductName'] = isc_html_escape($product['data']['prodname']); $GLOBALS['SNIPPETS']['CartItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CheckoutCartItem"); } } // Do we have a shipping price to show? if ($orderSummary['digitalOrder'] == 0) { $GLOBALS['ShippingCost'] = CurrencyConvertFormatPrice($orderSummary['shippingCost']); $GLOBALS['ShippingMethod'] = sprintf("%s %s %s", isc_html_escape($orderSummary['shippingProvider']), GetLang('For'), $GLOBALS['ShippingCost']); $GLOBALS['HideShoppingCartShippingCost'] = ''; $GLOBALS['ShippingProvider'] = isc_html_escape($orderSummary['shippingProvider']); if (count($orderSummary['shippingAddresses']) == 1) { $address = current($orderSummary['shippingAddresses']); $GLOBALS['ShippingAddress'] = $GLOBALS['ISC_CLASS_ACCOUNT']->FormatShippingAddress($address); } else { if (count($orderSummary['shippingAddresses']) > 1) { $GLOBALS['ShippingAddress'] = '<em>(Order will be shipped to multiple addresses)</em>'; } else { $GLOBALS['ShippingAddress'] = GetLang('NA'); } } // Show the shipping details $GLOBALS['HideShippingDetails'] = ''; } else { $GLOBALS['HideShippingDetails'] = 'display: none'; $GLOBALS['HideShoppingCartShippingCost'] = 'none'; $GLOBALS['ShippingAddress'] = GetLang('NotRequiredForDigitalDownloads'); $GLOBALS['ShippingMethod'] = GetLang('ShippingImmediateDownload'); } if (isset($orderSummary['billingAddressId'])) { $GLOBALS['BillingAddress'] = $GLOBALS['ISC_CLASS_ACCOUNT']->GetAndFormatShippingAddressById($orderSummary['billingAddressId']); } else { $GLOBALS['BillingAddress'] = $GLOBALS['ISC_CLASS_ACCOUNT']->FormatShippingAddress($orderSummary['billingAddress']); } // Do we have a handling cost to show? if (isset($orderSummary['handlingCost']) && $orderSummary['handlingCost'] > 0) { $GLOBALS['HandlingCost'] = CurrencyConvertFormatPrice($orderSummary['handlingCost']); } else { $GLOBALS['HideShoppingCartHandlingCost'] = 'none'; } // Format the item total $GLOBALS['ItemTotal'] = CurrencyConvertFormatPrice($orderSummary['itemTotal']); if ($orderSummary['wrappingCost'] > 0) { $GLOBALS['GiftWrappingTotal'] = CurrencyConvertFormatPrice($orderSummary['wrappingCost']); } else { $GLOBALS['HideGiftWrappingTotal'] = 'display: none'; } // Hide everything related to tax by default $GLOBALS['HideShoppingCartTaxCost'] = "none"; $GLOBALS['HideShoppingCartIncludedTaxCost'] = "none"; // Do we have any tax we need to show? if ($orderSummary['taxCost'] > 0) { $taxLines = ""; $taxLang = ""; if ($orderSummary['taxIncluded']) { $taxLang = "Included"; } // get the taxes from the addresses and merge them if they are from the same tax rate $taxes = array(); foreach ($orderSummary['vendors'] as $vendorId => $addresses) { foreach ($addresses as $addressId => $addressInfo) { $taxId = $addressInfo['taxId']; if (isset($taxes[$taxId])) { $taxes[$taxId]['taxCost'] += $addressInfo['taxCost']; } else { $taxes[$taxId] = array('taxName' => $addressInfo['taxName'], 'taxCost' => $addressInfo['taxCost'], 'taxRate' => $addressInfo['taxRate']); } } } $GLOBALS['SNIPPETS']['TaxLines'] = ""; // generate lines for each tax rate foreach ($taxes as $taxId => $tax) { $GLOBALS['TaxName'] = isc_html_escape(sprintf(GetLang($taxLang . 'TaxLine'), $tax['taxName'], $tax['taxRate'] / 1)); $GLOBALS['TaxCost'] = CurrencyConvertFormatPrice($tax['taxCost']); $taxLines .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CheckoutTaxLine"); } // if more than one tax rate is used, display a total line if (count($taxes) > 1) { $GLOBALS['TaxName'] = isc_html_escape(GetLang($taxLang . 'TotalTax')); $GLOBALS['TaxCost'] = CurrencyConvertFormatPrice($orderSummary['taxCost']); $taxLines .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("CheckoutTaxLine"); } $GLOBALS['SNIPPETS']['TaxLines'] = ""; $GLOBALS['SNIPPETS']['IncludedTax'] = ""; // are we displaying the tax before the total or after as included tax? if ($orderSummary['taxIncluded']) { $GLOBALS['SNIPPETS']['IncludedTax'] = $taxLines; } else { $GLOBALS['SNIPPETS']['TaxLines'] = $taxLines; } } // Format the grand total of the order $GLOBALS['TotalCost'] = CurrencyConvertFormatPrice($orderSummary['total']); $GLOBALS['HideAdjustedTotal'] = "none"; $GLOBALS['SNIPPETS']['GiftCertificates'] = ''; if ($orderSummary['adjustedTotal'] != $orderSummary['total']) { $GLOBALS['HideAdjustedTotal'] = ''; $GLOBALS['AdjustedTotalCost'] = $orderSummary['adjustedTotal']; } $GLOBALS['SNIPPETS']['Coupons'] = ''; if (count($orderSummary['coupons'])) { foreach ($orderSummary['coupons'] as $coupon) { $GLOBALS['CouponId'] = $coupon['couponid']; $GLOBALS['CouponCode'] = $coupon['couponcode']; // percent coupon if ($coupon['coupontype'] == 1) { $discount = $coupon['discount'] . "%"; } else { $discount = CurrencyConvertFormatPrice($coupon['discount']); } $GLOBALS['CouponDiscount'] = $discount; $GLOBALS['SNIPPETS']['Coupons'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ConfirmOrderCoupon"); } } // If we have any gift certificates, list those too if (!empty($orderSummary['giftCertificates'])) { foreach ($orderSummary['giftCertificates'] as $certificate) { $GLOBALS['GiftCertificateCode'] = isc_html_escape($certificate['giftcertcode']); $GLOBALS['GiftCertificateId'] = $certificate['giftcertid']; $GLOBALS['GiftCertificateBalance'] = CurrencyConvertFormatPrice($certificate['giftcertbalance']); $GLOBALS['GiftCertificateRemaining'] = CurrencyConvertFormatPrice($certificate['balanceremaining']); $GLOBALS['CertificateAmountUsed'] = CurrencyConvertFormatPrice($certificate['amountused']); $GLOBALS['SNIPPETS']['GiftCertificates'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("ConfirmOrderGiftCertificate"); } } // If the order total comes to $0.00, then we don't show the payment options and a lot of other things (because they have nothing to pay) if ($orderSummary['adjustedTotal'] == 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'] >= $orderSummary['adjustedTotal']) { $GLOBALS['PaymentButtonSwitch'] = "ShowContinueButton();"; $GLOBALS['HideLimitedCreditWarning'] = "none"; $GLOBALS['HideLimitedCreditPaymentOption'] = "none"; $GLOBALS['HideCreditPaymentMethods'] = "none"; $GLOBALS['RemainingCredit'] = $customer['custstorecredit'] - $orderSummary['adjustedTotal']; if ($GLOBALS['RemainingCredit'] > 0) { $GLOBALS['HideRemainingStoreCredit'] = ''; $GLOBALS['RemainingCredit'] = CurrencyConvertFormatPrice($GLOBALS['RemainingCredit']); } } else { $GLOBALS['Remaining'] = CurrencyConvertFormatPrice($orderSummary['adjustedTotal'] - $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'] >= $orderSummary['adjustedTotal']) { $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 = "\n\t\t\t\tSELECT orderid\n\t\t\t\tFROM [|PREFIX|]orders\n\t\t\t\tWHERE ordtoken='" . $GLOBALS['ISC_CLASS_DB']->Quote($_COOKIE['SHOP_ORDER_TOKEN']) . "' AND ordstatus=0\n\t\t\t"; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while ($order = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $entity = new ISC_ENTITY_ORDER(); $entity->delete($order['orderid'], false, true); } } // 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"; } // Save the information about the pending order in the checkout session, we'll be using it when they visit the next page $_SESSION['CHECKOUT']['PENDING_DATA'] = array("ITEM_TOTAL" => $orderSummary['itemTotal'], "TAX_COST" => number_format($orderSummary['taxCost'], GetConfig('DecimalPlaces'), ".", ""), "TAX_INCLUDED" => $orderSummary['taxIncluded'], "ORDER_TOTAL" => number_format($orderSummary['total'] - $GLOBALS['ISC_CLASS_CART']->api->Get('SUBTOTAL_DISCOUNT'), GetConfig('DecimalPlaces'), ".", ""), "GATEWAY_AMOUNT" => number_format($orderSummary['adjustedTotal'], GetConfig('DecimalPlaces'), ".", ""), "GIFTCERTIFICATE_AMOUNT" => number_format($orderSummary['giftCertificateTotal'], GetConfig('DecimalPlaces'), ".", "")); // Store information about each vendor in the order foreach ($orderSummary['vendors'] as $vendorId => $addressInfo) { foreach ($addressInfo as $addressId => $vendorInfo) { $_SESSION['CHECKOUT']['PENDING_DATA']['VENDORS'][$vendorId . '_' . $addressId] = array('ITEM_TOTAL' => $vendorInfo['itemTotal'], 'TAX_COST' => number_format($vendorInfo['taxCost'], GetConfig('DecimalPlaces'), ".", ""), 'TAX_RATE' => number_format($vendorInfo['taxRate'], GetConfig('DecimalPlaces'), ".", ""), 'TAX_NAME' => $vendorInfo['taxName'], 'ORDER_TOTAL' => number_format($vendorInfo['total'] - $GLOBALS['ISC_CLASS_CART']->api->Get('SUBTOTAL_DISCOUNT'), GetConfig('DecimalPlaces'), ".", "")); } } // If this is an anonymous checkout, save that if (isset($_POST['anonymousCheckout'])) { $_SESSION['CHECKOUT']['PENDING_DATA']['GUEST_CHECKOUT'] = 1; } else { $_SESSION['CHECKOUT']['PENDING_DATA']['GUEST_CHECKOUT'] = 0; } // Checkout out as a new customer and wishing to create an account, we need to save those details if (!CustomerIsSignedIn()) { if (isset($_POST['createAccount']) || GetConfig('GuestCheckoutCreateAccounts')) { // If we're automatically creating accounts, assign the user a random password $autoAccount = 0; if (isset($_POST['billing_Password'])) { $password = $_POST['billing_Password']; } if (!isset($_POST['createAccount']) && GetConfig('GuestCheckoutCreateAccounts')) { $password = substr(md5(uniqid(true)), 0, 8); $autoAccount = 1; } if (!isset($_SESSION['CHECKOUT']['CREATE_ACCOUNT']) && isset($_POST['billing_EmailAddress'])) { $_SESSION['CHECKOUT']['CREATE_ACCOUNT'] = 1; $_SESSION['CHECKOUT']['ACCOUNT_DETAILS'] = array('email' => $_POST['billing_EmailAddress'], 'password' => $password, 'firstname' => $_POST['billing_FirstName'], 'lastname' => $_POST['billing_LastName'], 'company' => $_POST['billing_CompanyName'], 'phone' => $_POST['billing_Phone'], 'autoAccount' => $autoAccount); } } else { unset($_SESSION['CHECKOUT']['CREATE_ACCOUNT']); unset($_SESSION['CHECKOUT']['ACCOUNT_DETAILS']); } } else { unset($_SESSION['CHECKOUT']['CREATE_ACCOUNT']); unset($_SESSION['CHECKOUT']['ACCOUNT_DETAILS']); } if (GetConfig('EnableOrderComments') == 1) { $GLOBALS['HideOrderComments'] = ""; } else { $GLOBALS['HideOrderComments'] = "none"; } if ($GLOBALS['ISC_CLASS_CART']->api->Get('SUBTOTAL_DISCOUNT') == 0) { $GLOBALS['HideOrderDiscount'] = "display : none"; } else { $GLOBALS['OrderDiscount'] = CurrencyConvertFormatPrice($GLOBALS['ISC_CLASS_CART']->api->Get('SUBTOTAL_DISCOUNT')); $GLOBALS['HideOrderDiscount'] = ""; } 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;"; } $GLOBALS['AdjustedTotalCost'] = CurrencyConvertFormatPrice($orderSummary['adjustedTotal']); }