Skip to content

Commit a3f4eee

Browse files
committed
Merge branch 'master' of https://github.com/razorpay/razorpay-woocommerce into 1cc-multiple-checkout
2 parents 5285cde + c58f0fb commit a3f4eee

File tree

5 files changed

+36
-6
lines changed

5 files changed

+36
-6
lines changed

includes/api/api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function rzp1ccInitRestApi()
8080

8181
// save abandoned cart data
8282
register_rest_route(
83-
RZP_1CC_ROUTES_BASE . '/',
83+
RZP_1CC_ROUTES_BASE,
8484
'abandoned-cart',
8585
array(
8686
'methods' => 'POST',

includes/api/order.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ function createWcOrder(WP_REST_Request $request)
9595
if (is_wp_error($orderId)) {
9696
$checkout_error = $orderId->get_error_message();
9797
}
98+
//Keep order in draft status untill customer info available
99+
updateOrderStatus($orderId, 'draft');
98100
} else {
99101
$existingOrder = wc_get_order($orderIdFromHash);
100102
$existingOrder->calculate_totals();
@@ -107,6 +109,8 @@ function createWcOrder(WP_REST_Request $request)
107109
if (is_wp_error($orderId)) {
108110
$checkout_error = $orderId->get_error_message();
109111
}
112+
//Keep order in draft status untill customer info available
113+
updateOrderStatus($orderId, 'draft');
110114
} else {
111115
$orderId = $woocommerce->session->get(RZP_1CC_CART_HASH . $cartHash);
112116
}
@@ -117,7 +121,7 @@ function createWcOrder(WP_REST_Request $request)
117121
if ($order) {
118122

119123
// To remove coupon added on order.
120-
$coupons = $order->get_used_coupons();
124+
$coupons = $order->get_coupon_codes();
121125
if (!empty($coupons)) {
122126
foreach ($coupons as $coupon) {
123127
$order->remove_coupon($coupon);
@@ -239,3 +243,12 @@ function createWcOrder(WP_REST_Request $request)
239243
return new WP_REST_Response($response, 400);
240244
}
241245
}
246+
247+
//Update order status according to the steps.
248+
function updateOrderStatus($orderId, $orderStatus)
249+
{
250+
wp_update_post(array(
251+
'ID' => $orderId,
252+
'post_status' => $orderStatus,
253+
));
254+
}

includes/api/save-abandonment-data.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ function saveCartAbandonmentData(WP_REST_Request $request)
3535
if (isset($razorpayData['receipt'])) {
3636
$wcOrderId = $razorpayData['receipt'];
3737

38+
if (isset($razorpayData['customer_details']['shipping_address'])) {
39+
//Update the order status to wc-pending as we have the customer address info at this point.
40+
updateOrderStatus($wcOrderId, 'wc-pending');
41+
42+
}
3843
$order = wc_get_order($wcOrderId);
3944
}
4045

readme.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: razorpay
33
Tags: razorpay, payments, india, woocommerce, ecommerce
44
Requires at least: 3.9.2
55
Tested up to: 5.9
6-
Stable tag: 3.3.0
6+
Stable tag: 3.4.0
77
Requires PHP: 5.6
88
License: GPLv2 or later
99
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -41,6 +41,9 @@ This is compatible with WooCommerce>=2.4, including the new 3.0 release. It has
4141

4242
== Changelog ==
4343

44+
= 3.4.0 =
45+
* Bug fix for magic checkout blank orders.
46+
4447
= 3.3.0 =
4548
* Magic checkout COD intelligence config moved from wooc dashboard to razorpay dashboard.
4649

@@ -276,6 +279,12 @@ Yes, please see https://github.com/razorpay/razorpay-woocommerce/wiki/Webhooks f
276279
Please get multi-currency enabled for your account. Once you have it enabled, you can install any plugin
277280
version higher than 2.0.0, which comes with native multi-currency support.
278281

282+
= How can I exclude Draft orders from woocommerce analytics reports? =
283+
284+
Please follow the below steps:
285+
1. Click on the ‘Analytics’ settings in the WooCommerce dashboard menu.
286+
2. Go to the ‘Excluded statuses’ section and select the checkbox for ‘Draft’ orders under the ‘Unregistered statuses’ section.
287+
279288
== Support ==
280289

281290
Visit [razorpay.com](https://razorpay.com/support/#request/merchant/technical-assistance) for support requests.

woo-razorpay.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* Plugin Name: Razorpay for WooCommerce
44
* Plugin URI: https://razorpay.com
55
* Description: Razorpay Payment Gateway Integration for WooCommerce
6-
* Version: 3.3.0
7-
* Stable tag: 3.3.0
6+
* Version: 3.4.0
7+
* Stable tag: 3.4.0
88
* Author: Team Razorpay
99
* WC tested up to: 6.2.2
1010
* Author URI: https://razorpay.com
@@ -1117,6 +1117,9 @@ function check_razorpay_response()
11171117
if (count($postIds) > 0)
11181118
{
11191119
$orderId = $postIds[0];
1120+
1121+
updateOrderStatus($orderId, 'wc-pending');
1122+
11201123
$order = wc_get_order($orderId);
11211124
rzpLogInfo("get_transient in check_razorpay_response: orderId $orderId");
11221125
}
@@ -1203,7 +1206,7 @@ function check_razorpay_response()
12031206
$razorpayOrderId = get_transient($sessionKey);
12041207
$razorpayData = $api->order->fetch($razorpayOrderId);
12051208

1206-
$this->updateOrderAddress($razorpayData['items'][0], $order);
1209+
$this->updateOrderAddress($razorpayData, $order);
12071210
}
12081211

12091212
$this->handleErrorCase($order);

0 commit comments

Comments
 (0)