Skip to content

Commit e8bbfa7

Browse files
Taras KubivIgor Liubarskyi
authored andcommitted
Merged in APITOCART-18519-fix-order-bug (pull request #49)
APITOCART-18519-fix-order-bug [MASTER] Approved-by: Oleg Syvak
2 parents d0070a3 + 4bbfe58 commit e8bbfa7

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

src/app/Services/Api2Cart.php

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ public function getOrderInfo( $store_id=null, $order_id=null )
665665
try{
666666

667667
$this->order->getConfig()->setApiKey('store_key', $store_id);
668-
$result = $this->order->orderInfo( $order_id ,'force_all');
668+
$result = $this->order->orderInfo( $order_id , null, 'force_all');
669669
$this->logApiCall( 'order.info.json', $result->getResult(), $result->getReturnCode(), $this->order->getConfig(), null, null, null, $result->getReturnMessage() ,['order_id'=>$order_id] );
670670

671671
if ($result->getReturnCode() == 0) {
@@ -901,6 +901,7 @@ public function updateProduct($store_id=null, $product_id=null, $fields=[])
901901
$result = $this->product->productUpdate(
902902
$product_id,
903903
null,
904+
null,
904905
(isset($fields['price'])) ? $fields['price'] : null,
905906
null,
906907
null,
@@ -914,15 +915,14 @@ public function updateProduct($store_id=null, $product_id=null, $fields=[])
914915
null,
915916
null,
916917
null,
917-
(isset($fields['name'])) ? $fields['name'] : null,
918-
null,
919918
null,
919+
(isset($fields['name'])) ? $fields['name'] : null,
920920
null,
921921
null,
922-
(isset($fields['description'])) ? $fields['description'] : null,
923922
null,
924923
null,
925924
null,
925+
(isset($fields['description'])) ? $fields['description'] : null,
926926
null,
927927
null,
928928
null,
@@ -1190,19 +1190,12 @@ public function addProductImage($store_id=null, $product_id=null, $fields=[])
11901190
$this->order->getConfig()->setApiKey('store_key', $store_id);
11911191

11921192
if ($fields) {
1193-
$result = $this->product->productImageAdd(
1194-
$product_id,
1195-
$fields['image_name'],
1196-
$fields['type'],
1197-
$fields['url'],
1198-
null,
1199-
null,
1200-
null,
1201-
null,
1202-
null,
1203-
null,
1204-
null
1205-
);
1193+
$model = new \Api2Cart\Client\Model\ProductImageAdd();
1194+
$model->setProductId($product_id)
1195+
->setType($fields['type'] ?? 'base')
1196+
->setUrl($fields['url'])
1197+
->setImageName($fields['image_name'] ?? '');
1198+
$result = $this->product->productImageAdd($model);
12061199

12071200
$this->logApiCall( 'product.image.add.json', $result->getResult(), $result->getReturnCode(), $this->product->getConfig(), null, null, null, $result->getReturnMessage(), array_merge(['product_id'=>$product_id],$fields) );
12081201

src/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"license": "MIT",
1010
"require": {
1111
"php": "^7.2.5",
12-
"api2cart/api2cart-php-sdk": "dev-master",
12+
"api2cart/api2cart-php-sdk": "2.1.1",
1313
"brotzka/laravel-dotenv-editor": "^2.1",
1414
"fideloper/proxy": "^4.2",
1515
"fruitcake/laravel-cors": "^1.0",

src/resources/views/business_cases/automatic_price_updating/index.blade.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,9 @@ function(data, type, row, meta){
362362
//update log count
363363
if ( presponse.data.log ){
364364
for (let k=0; k<presponse.data.log.length; k++){
365-
logItems.push( presponse.data.log[k] );
365+
if (k < 2) {//skip product.info
366+
logItems.push(presponse.data.log[k]);
367+
}
366368
}
367369
calculateLog();
368370
}
@@ -386,7 +388,7 @@ function(data, type, row, meta){
386388
}).catch(function (error) {
387389
$.unblockUI();
388390
389-
if ( typeof error.response.data.errors != 'undefined'){
391+
if ( typeof error.response != 'undefined' && typeof error.response.data.errors != 'undefined'){
390392
var err_msg = '<ul>';
391393
$.each(error.response.data.errors, function(index, value) {
392394
let obj = document.getElementById( index ); // $('#'+index)

0 commit comments

Comments
 (0)