-
Notifications
You must be signed in to change notification settings - Fork 0
/
guest_cart.php
109 lines (74 loc) · 2.06 KB
/
guest_cart.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
/**
* @Alok Dubey
* @2018
*/
require_once 'config.php';
require_once 'soapconfig.php';
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(!isset($quote_id))
{
$quote_id = $proxy->shoppingCartCreate($sessionId,$storeId);
}
if($qty && $product_id)
{
try{
$result_3 = $proxy->shoppingCartProductAdd($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,'quote_id'=>""),JSON_PRETTY_PRINT);
exit;
}
$result_cart = $proxy->shoppingCartInfo($sessionId, $quote_id);
}
if(isset($customer))
{
$result = $proxy->shoppingCartInfo($sessionId, $quote_id);
//var_dump($result);
$result=$result->items;
//print_r($result);exit;
foreach($result as $one_product)
{
//print_r($one_product->product_id);exit;
$product_id=$one_product->product_id;
$qty=$one_product->qty;
Mage::app();
Mage::app()->getTranslator()->init('frontend');
$cust = Mage::getModel('customer/customer')->load($customer);
//$done_d=Mage::getModel('sales/quote')->load($quote_id)->setCustomerId($customer)->save();
$cust['mode'] = 'customer';
$cust['customer_id']=$cust->entity_id;
$proxy->shoppingCartCustomerSet($sessionId, $quote_id, $cust);
$check_move=$proxy->shoppingCartProductMoveToCustomerQuote($sessionId, $quote_id, array(array(
'product_id' => $product_id,
'qty' => $qty,
'options' => null,
'bundle_option' => null,
'bundle_option_qty' => null,
'links' => null
)), $storeId);
}
$result_cart = $proxy->shoppingCartInfo($sessionId, $quote_id);
}
echo json_encode(array('sucess'=>"true",'quote_id'=>$result_cart->quote_id,'message'=>"Product successfully added to your cart",'data'=>$result_cart),JSON_PRETTY_PRINT);
//var_dump($result);
//print_r(json_encode($result));
?>