PluginProbe
Cashfree for WooCommerce / 4.8.0
Cashfree for WooCommerce v4.8.0
4.8.1 4.8.0 trunk 1.0 1.2 4.2.1 4.2.2 4.3.2 4.3.3 4.3.4 4.3.5 4.3.6 4.3.7 4.3.8 4.3.9 4.4.0 4.4.1 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.5.0 4.5.1 All 42 releases
cashfree / includes / request / class-wc-cashfree-request-billing.php

class-wc-cashfree-request-billing.php in Cashfree for WooCommerce 4.8.0, at includes/request/class-wc-cashfree-request-billing.php

90 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Billing request
4 */
5
6 defined( 'ABSPATH' ) || exit;
7
8 /**
9 * Billing request class.
10 */
11 class WC_Cashfree_Request_Billing {
12
13 /**
14 * Build request.
15 *
16 * @param WC_Order $order Order instance.
17 *
18 * @return array
19 */
20 public static function build( $order_id ) {
21 $order = new WC_Order( $order_id );
22 $billing_address=$order->get_address( 'billing' ) ;
23 $addressData = array();
24 $billingAddressArray = array();
25 $billingAddress = "";
26 if ( is_user_logged_in() ) {
27 $customer = new WC_Customer( $order->get_user_id() );
28 if(!empty($customer->get_billing_first_name())) {
29 $billingAddressArray['full_name'] = $customer->get_billing_first_name(). " ". $customer->get_billing_last_name();
30 }
31 if(!empty($customer->get_billing_address_1())) {
32 $billingAddressArray['address_1'] = substr($customer->get_billing_address_1(),0,254);
33 $billingAddress = $billingAddress." ".$customer->get_billing_address_1();
34 }
35 if(!empty($customer->get_billing_address_2())) {
36 $billingAddressArray['address_2'] = substr($customer->get_billing_address_2(),0,254);
37 $billingAddress = $billingAddress." ".$customer->get_billing_address_2();
38 }
39 if(!empty($customer->get_billing_city())) {
40 $billingAddressArray['city'] = substr($customer->get_billing_city(),0,254);
41 $billingAddress = $billingAddress." ".$customer->get_billing_city();
42 }
43 if(!empty($customer->get_billing_state())) {
44 $billingAddressArray['state'] = substr($customer->get_billing_state(),0,254);
45 $billingAddress = $billingAddress." ".$customer->get_billing_state();
46 }
47 if(!empty($customer->get_billing_country())) {
48 $billingAddressArray['country'] = substr($customer->get_billing_country(),0,254);
49 }
50 if(!empty($customer->get_billing_postcode())) {
51 $billingAddressArray['pincode'] = $customer->get_billing_postcode();
52 }
53 $addressData['data'] = $billingAddressArray;
54 $addressData['billingAddress'] = substr($billingAddress,0,254);
55 return $addressData;
56 } elseif(!empty($billing_address)) {
57 if(!empty($billing_address['first_name'])) {
58 $billingAddressArray['full_name'] = $billing_address['first_name']. " " . $billing_address['last_name'];
59 }
60 if(!empty($billing_address['address_1'])) {
61 $billingAddressArray['address_1'] = substr($billing_address['address_1'],0,254);
62 $billingAddress = $billingAddress." ".$billing_address['address_1'];
63 }
64 if(!empty($billing_address['address_2'])) {
65 $billingAddressArray['address_2'] = substr($billing_address['address_2'],0,254);
66 $billingAddress = $billingAddress." ".$billing_address['address_2'];
67 }
68 if(!empty($billing_address['city'])) {
69 $billingAddressArray['city'] = substr($billing_address['city'],0,254);
70 $billingAddress = $billingAddress." ".$billing_address['city'];
71 }
72 if(!empty($billing_address['state'])) {
73 $billingAddressArray['state'] = substr($billing_address['state'],0,254);
74 $billingAddress = $billingAddress." ".$billing_address['state'];
75 }
76 if(!empty($billing_address['country'])) {
77 $billingAddressArray['country'] = substr($billing_address['country'],0,254);
78 }
79 if(!empty($billing_address['postcode'])) {
80 $billingAddressArray['postcode'] = $billing_address['postcode'];
81 }
82 $addressData['data'] = $billingAddressArray;
83 $addressData['billingAddress'] = substr($billingAddress,0,254);
84 return $addressData;
85 } else {
86 return $addressData;
87 }
88 }
89 }
90