-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcoupon.php
More file actions
61 lines (46 loc) · 1.21 KB
/
coupon.php
File metadata and controls
61 lines (46 loc) · 1.21 KB
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
<?php
/**
* @author kem parson
* @copyright 2016
*/
ini_set('display_errors','On');
error_reporting(E_ALL);
$error='false';
$customer=$_REQUEST['custid'];
$coupon_code=$_REQUEST['code'];
if(empty($coupon_code))
{
$ret['error'] = 'Need a code for this page' ;
$error='true';
}
//ini_set('display_errors','On');
//error_reporting(E_ALL);
require_once ($_SERVER['DOCUMENT_ROOT'] .'/app/Mage.php');
require_once ('config.php');
$error='false';
Mage::app();
Mage::app()->getTranslator()->init('frontend');
Mage::app()->loadArea('frontend');
Mage::getSingleton('core/session', array('name' => 'frontend'));
$cust = Mage::getModel('customer/customer')->load($customer);
$quote = Mage::getModel('sales/quote')->loadByCustomer($cust);
$qid=$quote->getId();
$proxy = new SoapClient(Mage::getBaseUrl().'/api/v2_soap/?wsdl');
$sessionId = $proxy->login(APIUSER, APIKEY);
try
{
$result = $proxy->shoppingCartCouponAdd($sessionId, $qid, $coupon_code);
//var_dump($result);
}
catch (Exception $e) {
$message = $e->getMessage();
$ret['error'] = $message ;
$error='true';
}
if($error=='false')
{
$ret['sucess']="true";
}
$result=json_encode($ret);
echo $result;
?>