/** * Convert a google request format address to an ISC format address * * @param array $top The google formatted address array * * @return array The ISC format address **/ public function GetAddressFromResponse($top) { include_once ISC_BASE_PATH . '/lib/shipping.php'; $countryid = GetCountryIdByISO2($top['country-code']['VALUE']); $address = array('shipcity' => $top['city']['VALUE'], 'shipstate' => GetStateNameByAbbrev($top['region']['VALUE'], $countryid), 'shipzip' => $top['postal-code']['VALUE'], 'shipcountry' => GetCountryById($countryid), 'shipcountryid' => $countryid, 'shipstateid' => GetStateByAbbrev($top['region']['VALUE'], $countryid)); // If we don't have the contact name then this is an anonymous request so we dont have any of the // other personally identifyable information if (isset($top['contact-name']['VALUE'])) { $name = $top['contact-name']['VALUE']; $name = explode(' ', $name, 2); $address['shipfirstname'] = $name[0]; $address['shiplastname'] = $name[1]; $address['shipaddress1'] = $top['address1']['VALUE']; $address['shipaddress2'] = $top['address2']['VALUE']; $address['shipcompany'] = $top['company-name']['VALUE']; $address['shipemail'] = $top['email']['VALUE']; $address['shipphone'] = $top['phone']['VALUE']; } return $address; }
/** * Imports an actual product record in to the database. * * @param array Array of record data */ protected function _ImportRecord($record) { if (!$record['custconemail']) { $this->ImportSession['Results']['Failures'][] = implode(",", $record['original_record']) . " " . GetLang('ImportCustomersMissingEmail'); return; } if (!is_email_address($record['custconemail'])) { $this->ImportSession['Results']['Failures'][] = implode(",", $record['original_record']) . " " . GetLang('ImportCustomersInvalidEmail'); return; } $fillin = array('custconcompany', 'custconfirstname', 'custconlastname', 'custconphone'); foreach ($fillin as $fillkey) { if (!isset($record[$fillkey])) { $record[$fillkey] = ''; } } // Is there an existing customer with the same email? $customerId = 0; $existingFormSessionId = 0; $query = sprintf("select customerid from [|PREFIX|]customers where lower(custconemail)='%s'", $GLOBALS['ISC_CLASS_DB']->Quote(isc_strtolower($record['custconemail']))); $result = $GLOBALS["ISC_CLASS_DB"]->Query($query); if ($row = $GLOBALS["ISC_CLASS_DB"]->Fetch($result)) { // Overriding existing products, set the product id if (isset($this->ImportSession['OverrideDuplicates']) && $this->ImportSession['OverrideDuplicates'] == 1) { $customerId = $row['customerid']; $this->ImportSession['Results']['Updates'][] = $record['custconfirstname'] . " " . $record['custconlastname'] . " (" . $record['custconemail'] . ")"; } else { $this->ImportSession['Results']['Duplicates'][] = $record['custconfirstname'] . " " . $record['custconlastname'] . " (" . $record['custconemail'] . ")"; return; } if (isId($row['custformsessionid'])) { $existingFormSessionId = $row['custformsessionid']; } } $customerData = array('company' => $record['custconcompany'], 'firstname' => $record['custconfirstname'], 'lastname' => $record['custconlastname'], 'email' => $record['custconemail'], 'phone' => $record['custconphone']); if (isset($record['custpassword']) && $record['custpassword'] !== '') { $customerData['password'] = $record['custpassword']; } if (isset($record['custstorecredit'])) { $customerData['storecredit'] = DefaultPriceFormat($record['custstorecredit']); } if (isId($customerId)) { $customerData['customerid'] = $customerId; } // Are we placing the customer in a customer group? $groupId = 0; if (!empty($record['custgroup'])) { static $customerGroups; $groupName = strtolower($record['custgroup']); if (isset($customerGroups[$groupName])) { $groupId = $customerGroups[$groupName]; } else { $query = "\n\t\t\t\t\tSELECT customergroupid\n\t\t\t\t\tFROM [|PREFIX|]customer_groups\n\t\t\t\t\tWHERE LOWER(groupname)='" . $GLOBALS['ISC_CLASS_DB']->Quote($groupName) . "'\n\t\t\t\t"; $groupId = $GLOBALS['ISC_CLASS_DB']->FetchOne($query, 'customergroupid'); // Customer group doesn't exist, create it if (!$groupId) { $newGroup = array('name' => $record['custgroup'], 'discount' => 0, 'isdefault' => 0, 'categoryaccesstype' => 'all'); $entity = new ISC_ENTITY_CUSTOMERGROUP(); $groupId = $entity->add($newGroup); } if ($groupId) { $customerGroups[$groupName] = $groupId; } } } $customerData['customergroupid'] = $groupId; // Do we have a shipping address? $shippingData = array(); if (isset($record['shipfullname']) || isset($record['shipfirstname']) || isset($record['shipaddress1']) || isset($record['shipaddress2']) || isset($record['shipcity']) || isset($record['shipstate']) || isset($record['shipzip']) || isset($record['shipcountry'])) { $fillin = array('shipaddress1', 'shipaddress2', 'shipcity', 'shipstate', 'shipzip', 'shipcountry'); foreach ($fillin as $fillkey) { if (!isset($record[$fillkey])) { $record[$fillkey] = ''; } } $shippingData['shipfirstname'] = ''; $shippingData['shiplastname'] = ''; $shippingData['shipaddress1'] = $record['shipaddress1']; $shippingData['shipaddress2'] = $record['shipaddress2']; $shippingData['shipcity'] = $record['shipcity']; $shippingData['shipstate'] = $record['shipstate']; $shippingData['shipzip'] = $record['shipzip']; $shippingData['shipcountry'] = $record['shipcountry']; $shippingData['shipstateid'] = 0; $shippingData['shipcountryid'] = 0; $shippingData['shipdestination'] = ''; // Find the country and state $shippingData['shipcountryid'] = (int) GetCountryByName($record['shipcountry']); if (!$shippingData['shipcountryid']) { $shippingData['shipcountryid'] = (int) GetCountryIdByISO2($record['shipcountry']); } // Still nothing? 0 for the shipping country ID if (!$shippingData['shipcountryid']) { $shippingData['shipcountryid'] = 0; } if (isset($record['shipstate'])) { $shippingData['shipstateid'] = GetStateByName($record['shipstate'], $shippingData['shipcountryid']); } // Still nothing? 0 for the shipping state ID if (!$shippingData['shipstateid']) { $shippingData['shipstateid'] = 0; } if (!isset($record['shipfullname']) || $record['shipfullname'] == "") { if (isset($record['shipfirstname']) && $record['shipfirstname'] != '') { $shippingData['shipfirstname'] = $record['shipfirstname']; } else { $shippingData['shipfirstname'] = $customerData['firstname']; } if (isset($record['shiplastname']) && $record['shiplastname'] != '') { $shippingData['shiplastname'] = $record['shiplastname']; } else { $shippingData['shiplastname'] = $customerData['lastname']; } } if (!isset($record['shipphone']) && isset($record['custconphone'])) { $shippingData['shipphone'] = $record['custconphone']; } else { $shippingData['shipphone'] = $record['shipphone']; } /** * Handle any of the address custom fields that we might have */ if (!empty($this->customFields) && array_key_exists('custom', $record)) { $shippingData['shipformsessionid'] = $this->_importCustomFormfields(FORMFIELDS_FORM_ADDRESS, $record['custom']); if (!isId($shippingData['shipformsessionid'])) { unset($shippingData['shipformsessionid']); } } } /** * Handle any of the customer custom fields that we might have */ if (!empty($this->customFields) && array_key_exists('custom', $record)) { $formSessionId = $this->_importCustomFormfields(FORMFIELDS_FORM_ACCOUNT, $record['custom'], $existingFormSessionId); if (isId($formSessionId)) { $customerData['custformsessionid'] = $formSessionId; } } $customerData['is_import'] = true; $customerEntity = new ISC_ENTITY_CUSTOMER(); // New customer, insert in to DB if ($customerId == 0) { // Set a temporary password, retrievable later via lost password function if (!isset($customerData['password']) || $customerData['password'] == '') { $customerData['password'] = isc_substr(uniqid(rand(), true), 0, 10); } $customerData['token'] = GenerateCustomerToken(); $customerData['shipping_address'] = $shippingData; $rtn = $customerEntity->add($customerData); ++$this->ImportSession['Results']['SuccessCount']; } else { if (count($shippingData) > 0) { $query = sprintf("select shipid from [|PREFIX|]shipping_addresses where shipcustomerid='%d' and lower(shipaddress1)='%s' and lower(shipaddress2)='%s' and lower(shipcity)='%s' and lower(shipstate)='%s' and lower(shipcountry)='%s'", $GLOBALS['ISC_CLASS_DB']->Quote($customerId), $GLOBALS['ISC_CLASS_DB']->Quote($shippingData['shipaddress1']), $GLOBALS['ISC_CLASS_DB']->Quote($shippingData['shipaddress2']), $GLOBALS['ISC_CLASS_DB']->Quote($shippingData['shipcity']), $GLOBALS['ISC_CLASS_DB']->Quote($shippingData['shipstate']), $GLOBALS['ISC_CLASS_DB']->Quote($shippingData['shipcountry'])); $Result = $GLOBALS['ISC_CLASS_DB']->Query($query); $row = $GLOBALS['ISC_CLASS_DB']->Fetch($Result); // Address doesn't exist, we insert it if (!$row['shipid']) { $customerData['shipping_address'] = $shippingData; } } $rtn = $customerEntity->edit($customerData); } }
/** * Get the country ID * * Method will return the country ID if found * * @access protected * @param string $countryName The country name / ISO3 name / ISO2 name * @param string $properCountryName The referenced variable to set the proper country name if the record exists * @return int The country ID on success, FALSE if not found */ protected function getCountryId($countryName, &$properCountryName=null) { if (trim($countryName) == '') { return false; } if (strlen($countryName) == 2) { $countryId = GetCountryIdByISO2($countryName); } else if (strlen($countryName) == 3) { $countryId = GetCountryIdByISO3($countryName); } else { $countryId = GetCountryIdByName($countryName); } if (!$countryId || trim($countryId) == '') { return false; } $properCountryName = GetCountryById($countryId); return (int)$countryId; }
/** * Get Express Checkout Details step * When customer come back from paypal after they select the payment method and shipping address in paypal, * This function takes the shipping address and redirect customer to choose shipping provider page. */ private function GetExpressCheckoutDetails() { if(isset($_SESSION['CHECKOUT']['FromCartPage'])) { unset($_COOKIE['SHOP_ORDER_TOKEN']); } $merchant = $this->GetMerchantSettings(); if($merchant['testmode'] == 'YES') { $transactionURL = $this->_testTransactionURL; $transactionURI = $this->_testTransactionURI; } else { $transactionURL = $this->_liveTransactionURL; $transactionURI = $this->_liveTransactionURI; } $pp_array = array( 'METHOD' => 'GetExpressCheckoutDetails', 'USER' => $merchant['username'], 'PWD' => $merchant['password'], 'SIGNATURE' => $merchant['signature'], 'VERSION' => '53.0', 'PAYMENTACTION' => $merchant['transactionType'], 'TOKEN' => $_REQUEST['token'], 'NOTIFYURL' => $GLOBALS['ShopPath'].'/checkout.php?action=gateway_ping&provider='.$this->GetId(), ); $paypal_query = ''; foreach ($pp_array as $key => $value) { $paypal_query .= $key.'='.urlencode($value).'&'; } $paypal_query = rtrim($paypal_query, '&'); // get the customer details from paypal $result = $this->_ConnectToProvider($transactionURL, $transactionURI, $paypal_query); $nvpArray = $this->_DecodePaypalResult($result); if(strtolower($nvpArray['ACK']) == 'success') { $_SESSION['CHECKOUT']['PayPalExpressCheckout'] = $nvpArray; // if user started paypal express checkout at confirmation page, redirect user back to confirmation page if(isset($_COOKIE['SHOP_ORDER_TOKEN'])) { // Load the pending order $orders = LoadPendingOrdersByToken($_COOKIE['SHOP_ORDER_TOKEN']); if(!is_array($orders)) { @ob_end_clean(); header("Location: ".$GLOBALS['ShopPath']."/checkout.php?action=confirm_order"); die(); } $this->SetOrderData($orders); $this->DoExpressCheckoutPayment(); exit; } $countryID = GetCountryIdByISO2($nvpArray['SHIPTOCOUNTRYCODE']); $countryName = GetCountryById($countryID); $stateID = $this->GetStateId($countryID, $nvpArray['SHIPTOSTATE']); $stateName = GetStateById($stateID); $phone = ''; if(isset($nvpArray['PHONENUM'])) { // phone will only be available if (see ISC-937) // 1. seller chooses "On (Required Field)" for contact telephone // 2. and, buyer ticks "Share this phone number with <store_name>" $phone = $nvpArray['PHONENUM']; } $shipaddress2 = ''; if (isset($nvpArray['SHIPTOSTREET2'])) { $shipaddress2 = $nvpArray['SHIPTOSTREET2']; } $address = array( 'shipfirstname' => $nvpArray['FIRSTNAME'], 'shiplastname' => $nvpArray['LASTNAME'], 'shipcompany' => '', 'shipaddress1' => $nvpArray['SHIPTOSTREET'], 'shipaddress2' => $shipaddress2, 'shipcity' => $nvpArray['SHIPTOCITY'], 'shipstate' => $stateName, 'shipzip' => $nvpArray['SHIPTOZIP'], 'shipcountry' => $countryName, 'shipstateid' => $stateID, 'shipcountryid' => $countryID, 'shipdestination' => 'residential', 'shipphone' => $phone ); if(CustomerIsSignedIn()) { $GLOBALS['ISC_CLASS_CUSTOMER'] = GetClass('ISC_CUSTOMER'); $customerID = $GLOBALS['ISC_CLASS_CUSTOMER']->GetCustomerId(); $address['shipcustomerid'] = $customerID; // check if the customer's address we get back from paypal is already exist in the customer's ISC address book $addressid = $this->GetAddressID($address); if($addressid > 0) { //if address is already in ISC address book, set the ISC address id to session so it can be selected by default on the checkout page. $_SESSION['CHECKOUT']['SelectAddress'] = $addressid; } else { //if address isn't in ISC address book, add it to customer's address book. $_SESSION['CHECKOUT']['SelectAddress'] = $GLOBALS['ISC_CLASS_DB']->InsertQuery("shipping_addresses", $address, 1); } } $address['shipemail'] = $nvpArray['EMAIL']; $address['saveAddress'] = 0; $GLOBALS['ISC_CLASS_CHECKOUT'] = GetClass('ISC_CHECKOUT'); //set the address to the session $GLOBALS['ISC_CLASS_CHECKOUT'] -> SetOrderBillingAddress($address); if($nvpArray['FIRSTNAME']." ".$nvpArray['LASTNAME'] != $nvpArray['SHIPTONAME']) { $_SESSION['CHECKOUT']['GoToCheckoutStep'] = "BillingAddress"; $firstName = trim(preg_replace('/\s.*$/', '', $nvpArray['SHIPTONAME'])); $lastName = trim(str_replace($firstName, '', $nvpArray['SHIPTONAME'])); $address['shipfirstname'] = $firstName; $address['shiplastname'] = $lastName; } else { $_SESSION['CHECKOUT']['GoToCheckoutStep'] = "ShippingProvider"; } $GLOBALS['ISC_CLASS_CHECKOUT'] -> SetOrderShippingAddress($address); // Only want to display paypal as the payment provider on order confirmation page, as customer has already selected the pay with paypal previously, so save paypal in provider list in session, so confirmation page will read from the session. $_SESSION['CHECKOUT']['ProviderListHTML'] = $this->ParseTemplate('paypalexpress.providerlist', true); // Skip choose a billing and shipping address step if(GetConfig('CheckoutType') == 'single') { $returnURL = $GLOBALS['ShopPath']."/checkout.php"; } else { //set the address to the session $GLOBALS['ISC_CLASS_CHECKOUT']->SetOrderBillingAddress($address); $GLOBALS['ISC_CLASS_CHECKOUT']->SetOrderShippingAddress($address); $returnURL = $GLOBALS['ShopPath']."/checkout.php?action=choose_shipper"; } header("Location: ".$returnURL); } }
private function ParseAddress($record, $customerId, $index = '') { $shippingData = array(); $fillin = array('shipaddress1', 'shipaddress2', 'shipcity', 'shipstate', 'shipzip', 'shipcountry'); foreach ($fillin as $fillkey) { if (!isset($record[$fillkey . $index])) { $record[$fillkey . $index] = ''; } } if (isId($customerId)) { $shippingData["shipcustomerid"] = $customerId; } $shippingData['shipid'] = 0; if (!empty($record['shipid' . $index])) { $shippingData['shipid'] = $record['shipid' . $index]; } $shippingData['shipfirstname'] = $record['shipfirstname' . $index]; $shippingData['shiplastname'] = $record['shiplastname' . $index]; $shippingData['shipaddress1'] = $record['shipaddress1' . $index]; $shippingData['shipaddress2'] = $record['shipaddress2' . $index]; $shippingData['shipcity'] = $record['shipcity' . $index]; $shippingData['shipstate'] = $record['shipstate' . $index]; $shippingData['shipzip'] = $record['shipzip' . $index]; $shippingData['shipcountry'] = $record['shipcountry' . $index]; $shippingData['shipstateid'] = 0; $shippingData['shipcountryid'] = 0; $shippingData['shipdestination'] = ''; // Find the country and state $shippingData['shipcountryid'] = (int)GetCountryByName($record['shipcountry' . $index]); if(!$shippingData['shipcountryid']) { $shippingData['shipcountryid'] = (int)GetCountryIdByISO2($record['shipcountry' . $index]); } // Still nothing? 0 for the shipping country ID if(!$shippingData['shipcountryid']) { $shippingData['shipcountryid'] = 0; } if(isset($record['shipstate' . $index])) { $shippingData['shipstateid'] = GetStateByName($record['shipstate' . $index], $shippingData['shipcountryid']); } // Still nothing? 0 for the shipping state ID if(!$shippingData['shipstateid']) { $shippingData['shipstateid'] = 0; } if(!isset($record['shipphone' . $index]) && isset($record['custconphone' . $index])) { $shippingData['shipphone'] = $record['custconphone' . $index]; } else { $shippingData['shipphone'] = $record['shipphone' . $index]; } /** * Handle any of the address custom fields that we might have */ if (!empty($this->customFields) && array_key_exists('custom', $record)) { $shippingData['shipformsessionid'] = $this->_importCustomFormfields(FORMFIELDS_FORM_ADDRESS, $record['custom' . $index]); if (!isId($shippingData['shipformsessionid'])) { unset($shippingData['shipformsessionid']); } } return $shippingData; }
/** * Displays a template details form specific for an eBay site and selected category options * * @param int $siteId The eBay site to display a template for * @param array $categoryOptions The primary category options to customize the form * @param int $templateId Optional template Id to use to fill the form with * @return string The form HTML */ public function getTemplateForm($siteId, $categoryOptions, $templateId = 0) { // Load eBay XML cache $xmlContent = str_replace('xmlns=', 'ns=', $this->ReadCache($siteId)); $getEbayDetailsXml = new SimpleXMLElement($xmlContent); $currencyId = $this->getCurrencyFromSiteId($siteId); $currency = GetCurrencyById($currencyId); $this->template->assign('currency', $currency); $this->template->assign('currencyToken', $currency['currencystring']); $this->template->assign('options', $categoryOptions); $this->template->assign('auctionDurations', $this->getDurationOptions($categoryOptions['auction_durations'])); $this->template->assign('fixedDurations', $this->getDurationOptions($categoryOptions['fixed_durations'])); $paymentMethods = $categoryOptions['payment_methods']; asort($paymentMethods); $this->template->assign('paymentMethods', $this->getPaymentMethodOptions($paymentMethods)); // location details $this->template->assign('countries', GetCountryListAsIdValuePairs()); // shipping details // Options for shipping services $shippingServiceObj = $getEbayDetailsXml->xpath('/GeteBayDetailsResponse/ShippingServiceDetails'); $shippingServices = $this->getShippingAsOptions($shippingServiceObj); // Options for handling time $handlingTimeObject = $getEbayDetailsXml->xpath('/GeteBayDetailsResponse/DispatchTimeMaxDetails'); $handlingTimeArray = $this->convertEbayObjectToArray('DispatchTimeMax', 'Description', $handlingTimeObject); // remove the 0 days option as handling time is now required with ebay and 0 isnt valid unset($handlingTimeArray[0]); ksort($handlingTimeArray); $this->template->assign('handlingTimes', $handlingTimeArray); // Retrieving shipping cost type $this->template->assign('domesticShippingCostTypes', $shippingServices['Domestic']['ServiceTypes']); $this->template->assign('internationalShippingCostTypes', $shippingServices['International']['ServiceTypes']); // Shipping service Flat $domesticFlatServices = $shippingServices['Domestic']['Services']['Flat']; // is Pickup offered as a service? remove it from our service list and set it as a template var if (isset($domesticFlatServices['Other']['Pickup'])) { $this->template->assign('domesticPickupAllowed', true); unset($domesticFlatServices['Other']['Pickup']); } $this->template->assign('DomesticShippingServFlat', $domesticFlatServices); $this->template->assign('InternationalShippingServFlat', $shippingServices['International']['Services']['Flat']); // Shipping service Calculated if (!empty($shippingServices['Domestic']['Services']['Calculated'])) { $this->template->assign('DomesticShippingServCalculated', $shippingServices['Domestic']['Services']['Calculated']); } if (!empty($shippingServices['International']['Services']['Calculated'])) { $this->template->assign('InternationalShippingServCalculated', $shippingServices['International']['Services']['Calculated']); } // Shipping Service Package Details - only used for calculated shipping cost type $shippingPackageObj = $getEbayDetailsXml->xpath('/GeteBayDetailsResponse/ShippingPackageDetails'); $shippingPackageArr = $this->convertEbayObjectToArray('ShippingPackage', 'Description', $shippingPackageObj); $this->template->assign('DomesticShippingPackage', $shippingPackageArr); $this->template->assign('InternationalShippingPackage', $shippingPackageArr); // ship to locations $shippingLocationObj = $getEbayDetailsXml->xpath('/GeteBayDetailsResponse/ShippingLocationDetails'); $shippingLocationArr = $this->convertEbayObjectToArray('ShippingLocation', 'Description', $shippingLocationObj); asort($shippingLocationArr); $this->template->assign('ShipToLocations', $shippingLocationArr); // additional shipping details $salesTaxStatesObject = $getEbayDetailsXml->xpath('/GeteBayDetailsResponse/TaxJurisdiction'); $salesTaxStatesArray = $this->convertEbayObjectToArray('JurisdictionID', 'JurisdictionName', $salesTaxStatesObject); $this->template->assign('hasSalesTaxStates', !empty($salesTaxStatesArray)); asort($salesTaxStatesArray); $this->template->assign('salesTaxStates', $salesTaxStatesArray); // refund details $refundObject = $getEbayDetailsXml->xpath('/GeteBayDetailsResponse/ReturnPolicyDetails/Refund'); if ($refundObject) { $this->template->assign('refundOptions', $this->convertEbayObjectToArray('RefundOption', 'Description', $refundObject)); } $this->template->assign('refundSupported', (bool)$refundObject); $returnsWithinObject = $getEbayDetailsXml->xpath('/GeteBayDetailsResponse/ReturnPolicyDetails/ReturnsWithin'); if ($returnsWithinObject) { $this->template->assign('returnsWithinOptions', $this->convertEbayObjectToArray('ReturnsWithinOption', 'Description', $returnsWithinObject)); } $this->template->assign('returnsWithinSupported', (bool)$returnsWithinObject); $returnCostPaidByObject = $getEbayDetailsXml->xpath('/GeteBayDetailsResponse/ReturnPolicyDetails/ShippingCostPaidBy'); if ($returnCostPaidByObject) { $this->template->assign('returnCostPaidByOptions', $this->convertEbayObjectToArray('ShippingCostPaidByOption', 'Description', $returnCostPaidByObject)); } $this->template->assign('returnCostPaidBySupported', (bool)$returnCostPaidByObject); $returnDescriptionObject = $getEbayDetailsXml->xpath('/GeteBayDetailsResponse/ReturnPolicyDetails/Description'); $this->template->assign('returnDescriptionSupported', (bool)$returnDescriptionObject); // hit counter $availableHitCounters = array ('NoHitCounter','HiddenStyle','BasicStyle','RetroStyle'); $hitCounters = array(); foreach ($availableHitCounters as $counter) { $hitCounters[$counter] = GetLang($counter); } $this->template->assign('hitCounters', $hitCounters); // Paid upgrade options // Gallery Style $availableGalleryOptions = array ('None', 'Gallery', 'Plus', 'Featured'); $galleryOptions = array(); foreach ($availableGalleryOptions as $galleryOption) { $galleryOptions[$galleryOption] = GetLang('EbayGallery' . $galleryOption); } $this->template->assign('galleryOptions', $galleryOptions); // Listing enhancement $listingFeaturesObject = $getEbayDetailsXml->xpath('/GeteBayDetailsResponse/ListingFeatureDetails'); $supportedListingFeatures = array('BoldTitle','Border','FeaturedFirst','FeaturedPlus','GiftIcon','Highlight','HomePageFeatured','ProPack'); $listingFeatures = array(); if (isset($listingFeaturesObject[0])) { foreach ($listingFeaturesObject[0] as $featureCode => $availability) { //@ToDo add support for PowerSellerOnly and TopRatedSellerOnly options if (!in_array($featureCode, $supportedListingFeatures) || $availability != 'Enabled') { continue; } $listingFeatures[$featureCode] = GetLang($featureCode); } } $this->template->assign('listingFeatures', $listingFeatures); // any defaults we should set $this->template->assign('quantityOption', 'one'); $this->template->assign('useItemPhoto', true); $this->template->assign('locationCountry', GetCountryIdByName(GetConfig('CompanyCountry'))); $this->template->assign('locationZip', GetConfig('CompanyZip')); $this->template->assign('locationCityState', GetConfig('CompanyCity') . ', ' . GetConfig('CompanyState')); $this->template->assign('reservePriceOption', 'ProductPrice'); $this->template->assign('reservePriceCustom', $categoryOptions['minimum_reserve_price']); $this->template->assign('startPriceOption', 'ProductPrice'); $this->template->assign('startPriceCustom', 0.01); $this->template->assign('buyItNowPriceOption', 'ProductPrice'); $this->template->assign('buyItNowPriceCalcPrice', 10); $this->template->assign('buyItNowPriceCustom', 0.01); $this->template->assign('fixedBuyItNowPriceOption', 'ProductPrice'); $this->template->assign('fixedBuyItNowPriceCustom', 0.01); $this->template->assign('auctionDuration', 'Days_7'); $this->template->assign('fixedDuration', 'Days_7'); $this->template->assign('useDomesticShipping', false); $this->template->assign('useInternationalShipping', false); $this->template->assign('useSalesTax', false); $this->template->assign('hitCounter', 'BasicStyle'); $this->template->assign('galleryOption', 'Gallery'); $this->template->assign('domesticFlatCount', 0); $this->template->assign('domesticCalcCount', 0); $this->template->assign('internationalFlatCount', 0); $this->template->assign('internationalCalcCount', 0); // assign template specific variables if ($templateId) { $template = new ISC_ADMIN_EBAY_TEMPLATE($templateId); $this->template->assign('currency', $template->getCurrency()); // quantity if ($template->getQuantityToSell() == 1) { $quantityOption = 'one'; } else { $quantityOption = 'more'; $this->template->assign('moreQuantity', $template->getQuantityToSell()); } $this->template->assign('quantityOption', $quantityOption); // item photo $this->template->assign('useItemPhoto', $template->getUseItemPhoto()); // lot size $this->template->assign('lotSize', $template->getLotSize()); // location details $this->template->assign('locationCountry', GetCountryIdByISO2($template->getItemLocationCountry())); $this->template->assign('locationZip', $template->getItemLocationZip()); $this->template->assign('locationCityState', $template->getItemLocationCityState()); // selling method $this->template->assign('sellingMethod', $template->getSellingMethod()); if ($template->getSellingMethod() == self::CHINESE_AUCTION_LISTING) { // reserve price $this->template->assign('useReservePrice', $template->getReservePriceUsed()); $reservePriceOption = 'ProductPrice'; if ($template->getReservePriceUsed()) { $reservePriceOption = $template->getReservePriceOption(); if ($reservePriceOption == 'PriceExtra') { $this->template->assign('reservePriceCalcPrice', $template->getReservePriceCalcPrice()); $this->template->assign('reservePriceCalcOption', $template->getReservePriceCalcOption()); $this->template->assign('reservePriceCalcOperator', $template->getReservePriceCalcOperator()); } elseif ($reservePriceOption == 'CustomPrice') { $this->template->assign('reservePriceCustom', $template->getReservePriceCustomPrice()); } } $this->template->assign('reservePriceOption', $reservePriceOption); // start price $startPriceOption = $template->getStartPriceOption(); if ($startPriceOption == 'PriceExtra') { $this->template->assign('startPriceCalcPrice', $template->getStartPriceCalcPrice()); $this->template->assign('startPriceCalcOption', $template->getStartPriceCalcOption()); $this->template->assign('startPriceCalcOperator', $template->getStartPriceCalcOperator()); } elseif ($startPriceOption == 'CustomPrice') { $this->template->assign('startPriceCustom', $template->getStartPriceCustomPrice()); } $this->template->assign('startPriceOption', $startPriceOption); // buy it now price $this->template->assign('useBuyItNowPrice', $template->getBuyItNowPriceUsed()); $buyItNowPriceOption = 'ProductPrice'; if ($template->getBuyItNowPriceUsed()) { $buyItNowPriceOption = $template->getBuyItNowPriceOption(); if ($buyItNowPriceOption == 'PriceExtra') { $this->template->assign('buyItNowPriceCalcPrice', $template->getBuyItNowPriceCalcPrice()); $this->template->assign('buyItNowPriceCalcOption', $template->getBuyItNowPriceCalcOption()); $this->template->assign('buyItNowPriceCalcOperator', $template->getBuyItNowPriceCalcOperator()); } elseif ($buyItNowPriceOption == 'CustomPrice') { $this->template->assign('buyItNowPriceCustom', $template->getBuyItNowPriceCustomPrice()); } } $this->template->assign('buyItNowPriceOption', $buyItNowPriceOption); $this->template->assign('auctionDuration', $template->getListingDuration()); } else { // Fixed Price Item $fixedBuyItNowPriceOption = $template->getStartPriceOption(); if ($fixedBuyItNowPriceOption == 'PriceExtra') { $this->template->assign('fixedBuyItNowPriceCalcPrice', $template->getStartPriceCalcPrice()); $this->template->assign('fixedBuyItNowPriceCalcOption', $template->getStartPriceCalcOption()); $this->template->assign('fixedBuyItNowPriceCalcOperator', $template->getStartPriceCalcOperator()); } elseif ($fixedBuyItNowPriceOption == 'CustomPrice') { $this->template->assign('fixedBuyItNowPriceCustom', $template->getStartPriceCustomPrice()); } $this->template->assign('fixedBuyItNowPriceOption', $fixedBuyItNowPriceOption); $this->template->assign('fixedDuration', $template->getListingDuration()); } // payment details $this->template->assign('selectedPaymentMethods', $template->getPaymentMethods()); $this->template->assign('paypalEmailAddress', $template->getPayPalEmailAddress()); // domestic shipping $this->template->assign('useDomesticShipping', $template->getUseDomesticShipping()); if ($template->getUseDomesticShipping()) { $settings = $template->getDomesticShippingSettings(); $shippingType = $settings['cost_type']; $this->template->assign('domesticShippingCostType', $shippingType); $services = $template->getDomesticShippingServices(); // flat options if ($shippingType == 'Flat') { $this->template->assign('domesticFlatShippingServices', $services); $this->template->assign('domesticFlatCount', count($services)); } // calculated options else { $service = current($services); $this->template->assign('domesticPackageType', $settings['package_type']); $this->template->assign('domesticCalculatedShippingServices', $services); $this->template->assign('domesticCalcCount', count($services)); } $this->template->assign('domesticFreeShipping', $settings['is_free_shipping']); $this->template->assign('domesticGetItFast', $settings['get_it_fast']); $this->template->assign('domesticLocalPickup', $settings['offer_pickup']); $this->template->assign('domesticHandlingCost', $settings['handling_cost']); } // international shipping $this->template->assign('useInternationalShipping', $template->getUseInternationalShipping()); if ($template->getUseInternationalShipping()) { $settings = $template->getInternationalShippingSettings(); $shippingType = $settings['cost_type']; $this->template->assign('internationalShippingCostType', $shippingType); $services = $template->getInternationalShippingServices(); // flat options if ($shippingType == 'Flat') { $this->template->assign('internationalFlatShippingServices', $services); $this->template->assign('internationalFlatCount', count($services)); } // calculated options else { $service = current($services); $this->template->assign('internationalPackageType', $settings['package_type']); $this->template->assign('internationalCalculatedShippingServices', $services); $this->template->assign('internationalCalcCount', count($services)); } $this->template->assign('internationalFreeShipping', $settings['is_free_shipping']); $this->template->assign('internationalHandlingCost', $settings['handling_cost']); } // other shipping $this->template->assign('handlingTime', $template->getHandlingTime()); $this->template->assign('useSalesTax', $template->getUseSalesTax()); $this->template->assign('salesTaxState', $template->getSalesTaxState()); $this->template->assign('salesTaxPercent', $template->getSalesTaxPercent()); $this->template->assign('salesTaxIncludesShipping', $template->getShippingIncludedInTax()); // other details $this->template->assign('checkoutInstructions', $template->getCheckoutInstructions()); $this->template->assign('acceptReturns', $template->getReturnsAccepted()); $this->template->assign('returnOfferedAs', $template->getReturnOfferedAs()); $this->template->assign('returnsPeriod', $template->getReturnsPeriod()); $this->template->assign('returnCostPaidBy', $template->getReturnCostPaidBy()); $this->template->assign('additionalPolicyInfo', $template->getAdditionalPolicyInfo()); $this->template->assign('hitCounter', $template->getCounterStyle()); $this->template->assign('galleryOption', $template->getGalleryType()); $this->template->assign('selectedListingFeatures', $template->getListingFeatures()); } return $this->template->render('ebay.template.form.details.tpl'); }
/** * Ebay: Sent to a seller when a buyer completes the checkout process for an item. Not sent when an auction ends without bids. * * My notes: Seems to be triggered when the buyer's payment process for an AUCTION item has completed, is not fired for fixed price items which fire 'FixedPrice...' notifications instead * * @param array $body */ protected function _handleAuctionCheckoutComplete($body) { // The data fields in the notification are the same as those returned by the GetItemTransactions call with the default detail level. if (!empty ($body['Item']['ItemID']) && ISC_ADMIN_EBAY::validEbayItemId($body['Item']['ItemID'])) { // variables init $order = array(); $orderId = 1; $order['ShippingInsuranceCost'] = 0; $completedPaymentHoldStatus = array('None', 'Released'); $orderStatus = ORDER_STATUS_AWAITING_PAYMENT; $existingOrderId = 0; // Determine if the buyer purchase multiple items from the same seller if (!empty($body['TransactionArray']['Transaction']['ContainingOrder'])) { // Call the operation to get the order transaction. $orderId = $body['TransactionArray']['Transaction']['ContainingOrder']['OrderID']; // if the record already exist, check if we need to update existing orders, that the payment hasn't been cleared previously. $existingOrder = GetOrderByEbayOrderId($orderId); $orderTransaction = ISC_ADMIN_EBAY_OPERATIONS::getOrderTransactions($orderId); $transactions = $orderTransaction->OrderArray->Order->TransactionArray->Transaction; $order['SubTotal'] = (string) $orderTransaction->OrderArray->Order->Subtotal; $order['ShippingCost'] = (string) $orderTransaction->OrderArray->Order->ShippingServiceSelected->ShippingServiceCost; $order['ShippingInsuranceCost'] = 0; $order['GrandTotal'] = (string) $orderTransaction->OrderArray->Order->Total; $order['TotalQuantityPurchased'] = 0; foreach ($transactions as $transaction) { $convertedTransaction = (array) $transaction; $variationOptionsString = ''; if (isset($convertedTransaction['Variation']->VariationSpecifics)) { $variationNameValueList = (array) $convertedTransaction['Variation']->VariationSpecifics->NameValueList; $variationOptions = array(); $variationSpecifics = (array) $convertedTransaction['Variation']->VariationSpecifics; if (is_array($variationSpecifics['NameValueList'])) { foreach ($variationSpecifics['NameValueList'] as $option) { $variationOptions[(string) $option->Name] = (string) $option->Value; } } else { $variationOptions[(string) $variationSpecifics['NameValueList']->Name] = (string) $variationSpecifics['NameValueList']->Value; } $variationOptionsString = serialize($variationOptions); } $quantityPurchased = $convertedTransaction['QuantityPurchased']; $transactionPrice = $convertedTransaction['TransactionPrice']; $itemId = (string) $convertedTransaction['Item']->ItemID; $transactionId = (string) $convertedTransaction['TransactionID']; $totalTransactionPrice = $transactionPrice * $quantityPurchased; $order['Transaction'][] = array( 'QuantityPurchased' => $quantityPurchased, 'TransactionPrice' => $transactionPrice, 'ItemId' => $itemId, 'TotalTransactionPrice' => $totalTransactionPrice, 'VariationOptionsString' => $variationOptionsString, 'TransactionId' => $transactionId, ); $order['TotalQuantityPurchased'] += $quantityPurchased; $order['Currency'] = GetCurrencyByCode($body['TransactionArray']['Transaction']['AmountPaid']['!currencyID']); $buyerInfoShippingAddress = $body['TransactionArray']['Transaction']['Buyer']['BuyerInfo']['ShippingAddress']; $buyerEmailAddress = $body['TransactionArray']['Transaction']['Buyer']['Email']; } if ($existingOrder) { $existingOrderId = $existingOrder['orderid']; } } else { $transactions = $body['TransactionArray']; foreach ($transactions as $transaction) { $itemId = $body['Item']['ItemID']; $transactionId = $transaction['TransactionID']; $query = " SELECT * FROM [|PREFIX|]order_products WHERE ebay_item_id = '".$GLOBALS["ISC_CLASS_DB"]->Quote($itemId)."' AND ebay_transaction_id = '".$GLOBALS["ISC_CLASS_DB"]->Quote($transactionId)."' LIMIT 1 "; $res = $GLOBALS['ISC_CLASS_DB']->Query($query); $row = $GLOBALS['ISC_CLASS_DB']->Fetch($res); $eachItemPriceExTax = $transaction['TransactionPrice']['!']; $quantityPurchased = $transaction['QuantityPurchased']; $totalTransactionPrice = $quantityPurchased * $eachItemPriceExTax; $variationOptionsString = ''; // do we have a variation for this product? if (isset($transaction['Variation']['VariationSpecifics'])) { $variationNameValueList = $transaction['Variation']['VariationSpecifics']['NameValueList']; $variationOptions = array(); foreach ($variationNameValueList as $option) { $variationOptions[$option['Name']] = $option['Value']; } $variationOptionsString = serialize($variationOptions); } $order['TotalQuantityPurchased'] = $quantityPurchased; $order['SubTotal'] = $eachItemPriceExTax * $order['TotalQuantityPurchased']; $order['ShippingCost'] = $transaction['ShippingServiceSelected']['ShippingServiceCost']['!']; if (isset ($transaction['ShippingServiceSelected']['ShippingInsuranceCost']['!'])) { $order['ShippingInsuranceCost'] = $transaction['ShippingServiceSelected']['ShippingInsuranceCost']['!']; } $order['GrandTotal'] = $transaction['AmountPaid']['!']; $order['Transaction'][] = array( 'QuantityPurchased' => $quantityPurchased, 'TransactionPrice' => $eachItemPriceExTax, 'ItemId' => $itemId, 'TotalTransactionPrice' => $totalTransactionPrice, 'VariationOptionsString' => $variationOptionsString, 'TransactionId' => $transactionId, ); $order['Currency'] = GetCurrencyByCode($transaction['AmountPaid']['!currencyID']); $buyerInfoShippingAddress = $transaction['Buyer']['BuyerInfo']['ShippingAddress']; $buyerEmailAddress = $transaction['Buyer']['Email']; if (!$row) { // only process the new transaction break; } else { $existingOrderId = $row['orderorderid']; } } } $paymentHoldStatus = $body['TransactionArray']['Transaction']['Status']['PaymentHoldStatus']; if (in_array(trim($paymentHoldStatus), $completedPaymentHoldStatus)) { $orderStatus = ORDER_STATUS_AWAITING_FULFILLMENT; } if ($existingOrderId != 0) { if (!isset ($existingOrder)) { $existingOrder = GetOrder($existingOrderId, false, true, true); } // check if there're any existing order need to be updated. // in the case, paypal release the hold payment of buyer if ($existingOrder['ordstatus'] == ORDER_STATUS_AWAITING_PAYMENT && $orderStatus == ORDER_STATUS_AWAITING_FULFILLMENT) { // update the quantity for each transaction $GLOBALS["ISC_CLASS_DB"]->StartTransaction(); foreach ($order['Transaction'] as $eachTransaction) { // Get product Id try { $itemObj = new ISC_ADMIN_EBAY_ITEMS($eachTransaction['ItemId']); $productId = $itemObj->getProductId(); } catch (Exception $e) { $this->log->LogSystemDebug('ebay', $e->getMessage()); return false; } // update the item quantity in store $updatedData['quantity_remaining'] = $itemObj->getQuantityRemaining() - $eachTransaction['QuantityPurchased']; if (!$GLOBALS['ISC_CLASS_DB']->UpdateQuery('ebay_items', $updatedData, "ebay_item_id='" . $eachTransaction['ItemId'] . "'")) { $this->log->LogSystemDebug('ebay', $GLOBALS["ISC_CLASS_DB"]->Error()); $GLOBALS["ISC_CLASS_DB"]->RollbackTransaction(); return false; } if (!UpdateOrderStatus($existingOrderId, $orderStatus, true, true)) { $GLOBALS["ISC_CLASS_DB"]->RollbackTransaction(); return false; } } $GLOBALS["ISC_CLASS_DB"]->CommitTransaction(); // update the store inventory if necessary if (GetConfig('UpdateInventoryLevels') == 1) { DecreaseInventoryFromOrder($existingOrderId); } $this->log->LogSystemDebug('ebay', 'The status of the store order ('. $existingOrderId .') has been updated to: Awaiting Fulfillment'); } return true; } $order['ShippingTotalCost'] = $order['ShippingInsuranceCost'] + $order['ShippingCost']; // Buyer's address information $addressMap = array( 'Name', 'CompanyName', 'Street1', 'Street2', 'CityName', 'PostalCode', 'Country', 'CountryName', 'Phone', 'StateOrProvince', ); // Initialize the value, make sure it's not empty foreach ($addressMap as $key) { if (!isset($buyerInfoShippingAddress[$key])) { $buyerInfoShippingAddress[$key] = ''; } } $buyerCountryId = GetCountryIdByISO2($buyerInfoShippingAddress['Country']); $buyerStateId = GetStateByName($buyerInfoShippingAddress['StateOrProvince'], $buyerCountryId); $buyerStateName = $buyerInfoShippingAddress['StateOrProvince']; if (!$buyerStateId) { $buyerStateId = GetStateByAbbrev($buyerInfoShippingAddress['StateOrProvince'], $buyerCountryId); $stateInfo = GetStateInfoById($buyerStateId); $buyerStateName = $stateInfo['statename']; } // Tokenize buyer's first and last name $nameTokens = explode(' ', $buyerInfoShippingAddress['Name']); $buyerFirstName = $nameTokens[0]; $buyerLastName = ''; if (!empty($nameTokens[1])) { $buyerLastName = $nameTokens[1]; } $orderToken = generateOrderToken(); // Preparing data to be inserted to orders table $newOrder = array( 'ordtoken' => $orderToken, 'orderpaymentmodule' => '', 'orderpaymentmethod' => '', 'orderpaymentmodule' => '', 'extraInfo' => serialize(array()), 'orddefaultcurrencyid' => $order['Currency']['currencyid'], 'orddate' => time(), 'ordlastmodified' => time(), 'ordcurrencyid' => $order['Currency']['currencyid'], 'ordcurrencyexchangerate' => 1, 'ordipaddress' => GetIP(), 'ordcustmessage' => '', 'ordstatus' => $orderStatus, 'base_shipping_cost' => $order['ShippingTotalCost'], 'base_handling_cost' => 0, 'ordbillemail' => $buyerEmailAddress, 'ordbillfirstname' => $buyerFirstName, 'ordbilllastname' => $buyerLastName, 'ordbillcompany' => $buyerInfoShippingAddress['CompanyName'], 'ordbillstreet1' => $buyerInfoShippingAddress['Street1'], 'ordbillstreet2' => $buyerInfoShippingAddress['Street2'], 'ordbillsuburb' => $buyerInfoShippingAddress['CityName'], 'ordbillzip' => $buyerInfoShippingAddress['PostalCode'], 'ordbillcountrycode' => $buyerInfoShippingAddress['Country'], 'ordbillphone' => $buyerInfoShippingAddress['Phone'], 'ordbillstateid' => (int) $buyerStateId, 'ordbillstate' => $buyerStateName, 'ordbillcountry' => $buyerInfoShippingAddress['CountryName'], 'ordbillcountryid' => (int) $buyerCountryId, 'total_ex_tax' => $order['GrandTotal'], 'total_inc_tax' => $order['GrandTotal'], 'shipping_cost_ex_tax' => $order['ShippingTotalCost'], 'shipping_cost_inc_tax' => $order['ShippingTotalCost'], 'subtotal_inc_tax' => $order['SubTotal'], 'subtotal_ex_tax' => $order['SubTotal'], 'ebay_order_id' => $orderId, ); ResetStartingOrderNumber(); // Start the transaction $GLOBALS["ISC_CLASS_DB"]->StartTransaction(); // Inserting order data $newOrderId = $GLOBALS["ISC_CLASS_DB"]->InsertQuery('orders', $newOrder); if (!$newOrderId) { $this->log->LogSystemDebug('ebay', $GLOBALS["ISC_CLASS_DB"]->Error()); $GLOBALS["ISC_CLASS_DB"]->RollbackTransaction(); return false; } $orderAddress = array( 'first_name' => $buyerFirstName, 'last_name' => $buyerLastName, 'company' => $buyerInfoShippingAddress['CompanyName'], 'address_1' => $buyerInfoShippingAddress['Street1'], 'address_2' => $buyerInfoShippingAddress['Street2'], 'city' => $buyerInfoShippingAddress['CityName'], 'zip' => $buyerInfoShippingAddress['PostalCode'], 'country_iso2' => $buyerInfoShippingAddress['Country'], 'phone' => $buyerInfoShippingAddress['Phone'], 'total_items' => $order['TotalQuantityPurchased'], 'email' => $buyerEmailAddress, 'country_id' => (int) $buyerCountryId, 'country' => $buyerInfoShippingAddress['CountryName'], 'state_id' => (int) $buyerStateId, 'state' => $buyerStateName, 'order_id' => $newOrderId, ); $addressId = $GLOBALS['ISC_CLASS_DB']->insertQuery('order_addresses', $orderAddress); if (!$addressId) { $this->log->LogSystemDebug('ebay', $GLOBALS["ISC_CLASS_DB"]->Error()); $GLOBALS["ISC_CLASS_DB"]->RollbackTransaction(); return false; } // Inserting order shipping $orderShipping = array( 'order_address_id' => $addressId, 'order_id' => $newOrderId, 'base_cost' => $order['ShippingTotalCost'], 'cost_inc_tax' => $order['ShippingTotalCost'], 'cost_ex_tax' => $order['ShippingTotalCost'], 'method' => 'Available on eBay', ); if (!$GLOBALS['ISC_CLASS_DB']->insertQuery('order_shipping', $orderShipping)) { $this->log->LogSystemDebug('ebay', $GLOBALS["ISC_CLASS_DB"]->Error()); $GLOBALS["ISC_CLASS_DB"]->RollbackTransaction(); return false; } // Go thru each sold item in the order foreach ($order['Transaction'] as $eachTransaction) { // Get product Id try { $itemObj = new ISC_ADMIN_EBAY_ITEMS($eachTransaction['ItemId']); $productId = $itemObj->getProductId(); } catch (Exception $e) { $this->log->LogSystemDebug('ebay', $e->getMessage()); return false; } // Inserting order product $productObj = new ISC_PRODUCT($productId); $newProduct = array( 'orderorderid' => $newOrderId, 'ordprodid' => $productId, 'ordprodsku' => $productObj->GetSKU(), 'ordprodname' => $productObj->GetProductName(), 'ordprodtype' => $productObj->GetProductType(), 'ordprodqty' => $eachTransaction['QuantityPurchased'], 'base_price' => $eachTransaction['TransactionPrice'], 'price_ex_tax' => $eachTransaction['TransactionPrice'], 'price_inc_tax' => $eachTransaction['TransactionPrice'], 'price_tax' => 0, 'base_total' => $eachTransaction['TotalTransactionPrice'], 'total_ex_tax' => $eachTransaction['TotalTransactionPrice'], 'total_inc_tax' => $eachTransaction['TotalTransactionPrice'], 'total_tax' => 0, 'base_cost_price' => 0, 'cost_price_inc_tax' => 0, 'cost_price_inc_tax' => 0, 'cost_price_tax' => 0, 'ordprodweight' => $productObj->GetWeight(false), 'ordprodoptions' => $eachTransaction['VariationOptionsString'], 'ordprodvariationid' => $productObj->_prodvariationid, 'ordprodwrapid' => 0, 'ordprodwrapname' => '', 'base_wrapping_cost' => 0, 'wrapping_cost_ex_tax' => 0, 'wrapping_cost_inc_tax' => 0, 'wrapping_cost_tax' => 0, 'ordprodwrapmessage' => '', 'ordprodeventname' => '', 'ordprodeventdate' => 0, 'ordprodfixedshippingcost' => $productObj->GetFixedShippingCost(), 'order_address_id' => $addressId, 'ebay_item_id' => $eachTransaction['ItemId'], 'ebay_transaction_id' => $eachTransaction['TransactionId'], ); $orderProductId = $GLOBALS['ISC_CLASS_DB']->insertQuery('order_products', $newProduct); if (!$orderProductId) { $this->log->LogSystemDebug('ebay', $GLOBALS["ISC_CLASS_DB"]->Error()); $GLOBALS["ISC_CLASS_DB"]->RollbackTransaction(); return false; } if ($orderStatus == ORDER_STATUS_AWAITING_FULFILLMENT) { // update the item quantity in store $updatedData['quantity_remaining'] = $itemObj->getQuantityRemaining() - $eachTransaction['QuantityPurchased']; if (!$GLOBALS['ISC_CLASS_DB']->UpdateQuery('ebay_items', $updatedData, "ebay_item_id='" . $eachTransaction['ItemId'] . "'")) { $this->log->LogSystemDebug('ebay', $GLOBALS["ISC_CLASS_DB"]->Error()); $GLOBALS["ISC_CLASS_DB"]->RollbackTransaction(); return false; } } } $GLOBALS["ISC_CLASS_DB"]->CommitTransaction(); // update the store inventory if necessary if (GetConfig('UpdateInventoryLevels') == 1) { DecreaseInventoryFromOrder($newOrderId); } // Trigger new order notifications SendOrderNotifications($orderToken); $this->log->LogSystemDebug('ebay', 'An Item ('. $body['Item']['ItemID'] .') has been paid by the buyer and added to the store order (' . $newOrderId. ').'); return true; } return false; }