-
Notifications
You must be signed in to change notification settings - Fork 6
/
checkoutshiping.php
76 lines (61 loc) · 1.64 KB
/
checkoutshiping.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
<?php
/**
* @author kem parson
* @copyright 2016
*/
//ini_set('display_errors','On');
//error_reporting(E_ALL);
$customer=$_REQUEST['custid'];
require_once ($_SERVER['DOCUMENT_ROOT'] .'/app/Mage.php');
require_once ('config.php');
Mage::app();
Mage::app()->getTranslator()->init('frontend');
Mage::getSingleton('core/session', array('name' => 'frontend'));
//$product = Mage::getModel('catalog/product')->load($productId);
$cust = Mage::getModel('customer/customer')->load($customer);
$quote = Mage::getModel('sales/quote')->loadByCustomer($cust);
$qid=$quote->getId();
function getshiping($qid)
{
$proxy = new SoapClient(Mage::getBaseUrl().'/api/v2_soap/?wsdl');
$sessionId = $proxy->login(APIUSER, APIKEY);
try{
$result = $proxy->shoppingCartShippingList($sessionId, $qid);
//var_dump($result);
$i=0;
foreach ($result as $method):
$ret[$i]['code']=$method->code;
$ret[$i]['method']=$method->method ;
$ret[$i]['price']=$method->price ;
$i++;
endforeach;
return array_values($ret);
}
catch (Exception $e) {
$message = $e->getMessage();
return $reter['error']=$message ;
return $reter;
}
}
function setshiping($qid)
{
$code=$_REQUEST['code'];
$proxy = new SoapClient(Mage::getBaseUrl().'/api/v2_soap/?wsdl');
$sessionId = $proxy->login(APIUSER, APIKEY);
try
{
$result = $proxy->shoppingCartShippingMethod($sessionId, $qid, $code);
$ret['sucess']="true";
return $ret;
}
catch (Exception $e) {
$message = $e->getMessage();
return $reter['error']=$message ;
return $reter;
}
}
if ($_REQUEST['action']=="setshiping")
echo json_encode(setshiping($qid ));
else
echo json_encode (getshiping($qid));
?>