// Merge -> revision 8014
This commit is contained in:
@@ -89,7 +89,7 @@ class eBayRequest
|
||||
|
||||
$this->apiUrl = 'https://api.ebay.com/ws/api.dll';
|
||||
$this->apiCall = $apiCall;
|
||||
$this->compatibilityLevel = 719;
|
||||
$this->compatibilityLevel = 741;
|
||||
|
||||
$this->runame = 'Prestashop-Prestash-70a5-4-pepwa';
|
||||
|
||||
@@ -355,7 +355,7 @@ class eBayRequest
|
||||
|
||||
|
||||
/******************************************************************/
|
||||
/** Add Product Methods *******************************************/
|
||||
/** Add / Update / End Product Methods ****************************/
|
||||
/******************************************************************/
|
||||
|
||||
|
||||
@@ -374,7 +374,7 @@ class eBayRequest
|
||||
$requestXml .= ' <ErrorLanguage>fr_FR</ErrorLanguage>'."\n";
|
||||
$requestXml .= ' <WarningLevel>High</WarningLevel>'."\n";
|
||||
$requestXml .= ' <Item>'."\n";
|
||||
$requestXml .= ' <SKU>prestashop-'.$datas['id_product'].(isset($datas['reference']) ? '-'.$datas['reference'] : '').'</SKU>';
|
||||
$requestXml .= ' <SKU>prestashop-'.$datas['id_product'].'</SKU>';
|
||||
$requestXml .= ' <Title>'.substr($datas['name'], 0, 55).'</Title>'."\n";
|
||||
if (isset($datas['pictures']))
|
||||
{
|
||||
@@ -503,7 +503,7 @@ class eBayRequest
|
||||
$requestXml .= ' <WarningLevel>High</WarningLevel>'."\n";
|
||||
$requestXml .= ' <Item>'."\n";
|
||||
$requestXml .= ' <ItemID>'.$datas['itemID'].'</ItemID>'."\n";
|
||||
$requestXml .= ' <SKU>prestashop-'.$datas['id_product'].(isset($datas['reference']) ? '-'.$datas['reference'] : '').'</SKU>';
|
||||
$requestXml .= ' <SKU>prestashop-'.$datas['id_product'].'</SKU>';
|
||||
$requestXml .= ' <Quantity>'.$datas['quantity'].'</Quantity>'."\n";
|
||||
$requestXml .= ' <StartPrice>'.$datas['price'].'</StartPrice>'."\n";
|
||||
if (Configuration::get('EBAY_SYNC_OPTION_RESYNC') != 1)
|
||||
@@ -579,6 +579,86 @@ class eBayRequest
|
||||
|
||||
|
||||
|
||||
function endFixedPriceItem($datas = array())
|
||||
{
|
||||
// Check data
|
||||
if (!$datas)
|
||||
return false;
|
||||
|
||||
// Set Api Call
|
||||
$this->apiCall = 'EndFixedPriceItem';
|
||||
|
||||
// Build the request Xml string
|
||||
$requestXml = '<?xml version="1.0" encoding="utf-8"?>'."\n";
|
||||
$requestXml .= '<EndFixedPriceItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">'."\n";
|
||||
$requestXml .= ' <ErrorLanguage>fr_FR</ErrorLanguage>'."\n";
|
||||
$requestXml .= ' <WarningLevel>High</WarningLevel>'."\n";
|
||||
$requestXml .= ' <ItemID>'.$datas['itemID'].'</ItemID>'."\n";
|
||||
$requestXml .= ' <SKU>prestashop-'.$datas['id_product'].'</SKU>';
|
||||
$requestXml .= ' <EndingReason>NotAvailable</EndingReason>'."\n";
|
||||
$requestXml .= ' <RequesterCredentials>'."\n";
|
||||
$requestXml .= ' <eBayAuthToken>'.Configuration::get('EBAY_API_TOKEN').'</eBayAuthToken>'."\n";
|
||||
$requestXml .= ' </RequesterCredentials>'."\n";
|
||||
$requestXml .= ' <WarningLevel>High</WarningLevel>'."\n";
|
||||
$requestXml .= '</EndFixedPriceItemRequest>'."\n";
|
||||
|
||||
|
||||
// Send the request and get response
|
||||
$responseXml = $this->makeRequest($requestXml);
|
||||
if (stristr($responseXml, 'HTTP 404') || $responseXml == '')
|
||||
{
|
||||
$this->error = 'Error sending '.$this->apiCall.' request';
|
||||
return false;
|
||||
}
|
||||
|
||||
// Loading XML tree in array
|
||||
$this->response = simplexml_load_string($responseXml);
|
||||
|
||||
|
||||
// Checking Errors
|
||||
$this->error = '';
|
||||
$this->errorCode = '';
|
||||
if (isset($this->response->Errors) && isset($this->response->Ack) && (string)$this->response->Ack != 'Success' && (string)$this->response->Ack != 'Warning')
|
||||
foreach ($this->response->Errors as $e)
|
||||
{
|
||||
// if product no longer on eBay, we log the error code
|
||||
if ((int)$e->ErrorCode == 291)
|
||||
$this->errorCode = (int)$e->ErrorCode;
|
||||
|
||||
// We log error message
|
||||
if ($e->SeverityCode == 'Error')
|
||||
{
|
||||
if ($this->error != '')
|
||||
$this->error .= '<br />';
|
||||
$this->error .= (string)$e->LongMessage;
|
||||
if (isset($e->ErrorParameters->Value))
|
||||
$this->error .= '<br />'.(string)$e->ErrorParameters->Value;
|
||||
}
|
||||
}
|
||||
|
||||
// Checking Success
|
||||
$this->itemID = 0;
|
||||
if (isset($this->response->Ack) && ((string)$this->response->Ack == 'Success' || (string)$this->response->Ack == 'Warning'))
|
||||
{
|
||||
$this->fees = 0;
|
||||
$this->itemID = (string)$this->response->ItemID;
|
||||
if (isset($this->response->Fees->Fee))
|
||||
foreach ($this->response->Fees->Fee as $f)
|
||||
$this->fees += (float)$f->Fee;
|
||||
}
|
||||
elseif ($this->error == '')
|
||||
$this->error = 'Sorry, technical problem, try again later.';
|
||||
|
||||
if (!empty($this->error))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -653,7 +733,7 @@ class eBayRequest
|
||||
foreach ($datas['variations'] as $key => $variation)
|
||||
{
|
||||
$requestXml .= ' <Variation>'."\n";
|
||||
$requestXml .= ' <SKU>prestashop-'.$key.(isset($variation['reference']) ? '-'.$variation['reference'] : '').'</SKU>'."\n";
|
||||
$requestXml .= ' <SKU>prestashop-'.$key.'</SKU>'."\n";
|
||||
$requestXml .= ' <StartPrice>'.$variation['price'].'</StartPrice>'."\n";
|
||||
$requestXml .= ' <Quantity>'.$variation['quantity'].'</Quantity>'."\n";
|
||||
$requestXml .= ' <VariationSpecifics>'."\n";
|
||||
@@ -929,6 +1009,18 @@ class eBayRequest
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/******************************************************************/
|
||||
/** Order Methods *************************************************/
|
||||
/******************************************************************/
|
||||
@@ -1068,6 +1160,9 @@ class eBayRequest
|
||||
'shippingServiceCost' => (string)$order->ShippingServiceSelected->ShippingServiceCost,
|
||||
'email' => (string)$order->TransactionArray->Transaction[0]->Buyer->Email,
|
||||
'product_list' => $itemList,
|
||||
'payment_method' => (string)$order->CheckoutStatus->PaymentMethod,
|
||||
'id_order_seller' => (string)$order->ShippingDetails->SellingManagerSalesRecordNumber,
|
||||
'date_add' => substr((string)$order->CreatedTime, 0, 10).' '.substr((string)$order->CreatedTime, 11, 8),
|
||||
//'object' => $order
|
||||
);
|
||||
}
|
||||
|
||||
+33
-3
@@ -25,6 +25,9 @@
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
// Security
|
||||
if (!defined('_PS_VERSION_'))
|
||||
exit;
|
||||
|
||||
// Loading eBay Class Request
|
||||
if (file_exists(dirname(__FILE__).'/eBayRequest.php'))
|
||||
@@ -420,9 +423,12 @@ class Ebay extends Module
|
||||
|
||||
// Validate order
|
||||
$paiement = new eBayPayment();
|
||||
$paiement->validateOrder(intval($cartAdd->id), Configuration::get('PS_OS_PAYMENT'), floatval($cartAdd->getOrderTotal(true, 3)), 'Paypal eBay', NULL, array(), intval($cartAdd->id_currency));
|
||||
$paiement->validateOrder(intval($cartAdd->id), Configuration::get('PS_OS_PAYMENT'), floatval($cartAdd->getOrderTotal(true, 3)), 'eBay '.$order['payment_method'].' '.$order['id_order_seller'], NULL, array(), intval($cartAdd->id_currency));
|
||||
$id_order = $paiement->currentOrder;
|
||||
|
||||
// Fix on date
|
||||
Db::getInstance()->autoExecute(_DB_PREFIX_.'orders', array('date_add' => pSQL($order['date_add'])), 'UPDATE', '`id_order` = '.(int)$id_order);
|
||||
|
||||
// Fix on sending e-mail
|
||||
Db::getInstance()->autoExecute(_DB_PREFIX_.'customer', array('email' => pSQL($order['email'])), 'UPDATE', '`id_customer` = '.(int)$id_customer);
|
||||
|
||||
@@ -1514,8 +1520,19 @@ class Ebay extends Module
|
||||
$itemID = Db::getInstance()->getValue('SELECT `id_product_ref` FROM `'._DB_PREFIX_.'ebay_product` WHERE `id_product` = '.(int)$product->id.' AND `id_attribute` = '.(int)$datasTmp['id_attribute']);
|
||||
if ($itemID)
|
||||
{
|
||||
// Update
|
||||
// Get Item ID
|
||||
$datasTmp['itemID'] = $itemID;
|
||||
|
||||
// Delete or Update
|
||||
if ($datasTmp['quantity'] < 1)
|
||||
{
|
||||
// Delete
|
||||
if ($ebay->endFixedPriceItem($datasTmp))
|
||||
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'ebay_product` WHERE `id_product_ref` = \''.pSQL($datasTmp['itemID']).'\'');
|
||||
}
|
||||
else
|
||||
{
|
||||
// Update
|
||||
if ($ebay->reviseFixedPriceItem($datasTmp))
|
||||
Db::getInstance()->autoExecute(_DB_PREFIX_.'ebay_product', array('date_upd' => pSQL($date)), 'UPDATE', '`id_product_ref` = '.(int)$itemID);
|
||||
|
||||
@@ -1529,6 +1546,7 @@ class Ebay extends Module
|
||||
Db::getInstance()->autoExecute(_DB_PREFIX_.'ebay_product', array('id_country' => 8, 'id_product' => (int)$product->id, 'id_attribute' => (int)$datasTmp['id_attribute'], 'id_product_ref' => pSQL($ebay->itemID), 'date_add' => pSQL($date), 'date_upd' => pSQL($date)), 'INSERT');
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add
|
||||
@@ -1562,8 +1580,19 @@ class Ebay extends Module
|
||||
|
||||
if ($itemID)
|
||||
{
|
||||
// Update
|
||||
// Get Item ID
|
||||
$datas['itemID'] = $itemID;
|
||||
|
||||
// Delete or Update
|
||||
if ($datas['quantity'] < 1)
|
||||
{
|
||||
// Delete
|
||||
if ($ebay->endFixedPriceItem($datas))
|
||||
Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'ebay_product` WHERE `id_product_ref` = \''.pSQL($datas['itemID']).'\'');
|
||||
}
|
||||
else
|
||||
{
|
||||
// Update
|
||||
if ($ebay->reviseFixedPriceItem($datas))
|
||||
Db::getInstance()->autoExecute(_DB_PREFIX_.'ebay_product', array('date_upd' => pSQL($date)), 'UPDATE', '`id_product_ref` = '.(int)$itemID);
|
||||
|
||||
@@ -1577,6 +1606,7 @@ class Ebay extends Module
|
||||
Db::getInstance()->autoExecute(_DB_PREFIX_.'ebay_product', array('id_country' => 8, 'id_product' => (int)$product->id, 'id_attribute' => 0, 'id_product_ref' => pSQL($ebay->itemID), 'date_add' => pSQL($date), 'date_upd' => pSQL($date)), 'INSERT');
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Add
|
||||
|
||||
Reference in New Issue
Block a user