-
Notifications
You must be signed in to change notification settings - Fork 0
/
cart_remove_product.php
90 lines (70 loc) · 1.69 KB
/
cart_remove_product.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
/**
* @author Alok Dubey
* @ 2018
*/
if(isset($_REQUEST['quote_id']))
{
$quote_id=$_REQUEST['quote_id'];
}
$product_id=$_REQUEST['product_id'];
$qty=$_REQUEST['qty'];
if(isset($_REQUEST['customer_id']))
{
$customer=$_REQUEST['customer_id'];
}
$storeId=1;
if(!$product_id || !$qty)
{
$ret="parameter missing";
echo json_encode(array('sucess'=>"false",'message'=>$ret),JSON_PRETTY_PRINT);
exit;
}
if(!isset($quote_id) && !isset($customer))
{
$ret="quote_id or customer_id is mandatory";
echo json_encode(array('sucess'=>"false",'message'=>$ret),JSON_PRETTY_PRINT);
exit;
}
//print_r($product_id);exit;
require_once 'config.php';
require_once 'soapconfig.php';
Mage::app();
Mage::app()->getTranslator()->init('frontend');
Mage::getSingleton('core/session', array('name' => 'frontend'));
//print_r($storeId);exit;
if(isset($customer))
{
$cust = Mage::getModel('customer/customer')->load($customer);
$quote = Mage::getModel('sales/quote')->loadByCustomer($cust);
$quote_id=$quote->getId();
//print_r($quote_id);exit;
}
try
{
$result = $proxy->shoppingCartProductRemove($sessionId, $quote_id, array(array(
'product_id' => $product_id,
'qty' => $qty,
'options' => null,
'bundle_option' => null,
'bundle_option_qty' => null,
'links' => null
)), $storeId);
}
catch (Exception $e) {
$message = $e->getMessage();
echo json_encode(array('sucess'=>"false",'message'=>$message),JSON_PRETTY_PRINT);
exit;
}
//var_dump($result);
if($result=="true")
{
$ret="Product Remove from cart successfully";
echo json_encode(array('sucess'=>"true",'message'=>$ret),JSON_PRETTY_PRINT);
}
else
{
$ret="Opps something went worng";
echo json_encode(array('sucess'=>"false",'message'=>$ret),JSON_PRETTY_PRINT);
}
?>