Version Description
- Bug fix for Stock Management issue on magic checkout buy now option.
- Bug fix for Cart page checkout style issue on magic checkout.
- Optimize latency issue.
- Bug fix for PG title missing on invoice for magic checkout.
Download this release
Release Info
Developer | razorpay |
Plugin | Razorpay for WooCommerce |
Version | 3.0.1 |
Comparing to | |
See all releases |
Code changes from version 3.0.0 to 3.0.1
- btn-1cc-checkout.js +1 -3
- includes/api/cart.php +22 -11
- includes/api/order.php +19 -10
- readme.txt +7 -1
- templates/rzp-cart-checkout-btn.php +1 -1
- woo-razorpay.php +7 -8
btn-1cc-checkout.js
CHANGED
@@ -216,10 +216,8 @@ window.addEventListener('DOMContentLoaded', function() {
|
|
216 |
document.getElementById('error-message').innerHTML = "<p style='margin-top: revert;text-color: #e2401c !important;color: #e80707;'>Order could not be placed as your cart is empty.</p>";
|
217 |
} else if (e.response.code == 'ORDER_CREATION_FAILED'){
|
218 |
document.getElementById('error-message').innerHTML = "<p style='margin-top: revert;text-color: #e2401c !important;color: #e80707;'>Razorpay Error: Order could not be placed, please try again after sometime.</p>";
|
219 |
-
} else if (e.response.code == 'MIN_CART_AMOUNT_CHECK_FAILED'){
|
220 |
document.getElementById('error-message').innerHTML = "<p style='margin-top: revert;text-color: #e2401c !important;color: #e80707;'>"+e.response.message+"</p>";
|
221 |
-
} else if (e.response.code == 'WOOCOMMERCE_ORDER_CREATION_FAILED'){
|
222 |
-
document.getElementById('error-message').innerHTML = "<p style='margin-top: revert;text-color: #e2401c !important;color: #e80707;'>Order could not be placed, please connect with the "+rzp1ccCheckoutData.blogname+"</p>";
|
223 |
} else {
|
224 |
document.getElementById('error-message').innerHTML = "<p style='margin-top: revert;text-color: #e2401c !important;color: #e80707;'>Something went wrong, please try again after sometime.</p>";
|
225 |
}
|
216 |
document.getElementById('error-message').innerHTML = "<p style='margin-top: revert;text-color: #e2401c !important;color: #e80707;'>Order could not be placed as your cart is empty.</p>";
|
217 |
} else if (e.response.code == 'ORDER_CREATION_FAILED'){
|
218 |
document.getElementById('error-message').innerHTML = "<p style='margin-top: revert;text-color: #e2401c !important;color: #e80707;'>Razorpay Error: Order could not be placed, please try again after sometime.</p>";
|
219 |
+
} else if (e.response.code == 'MIN_CART_AMOUNT_CHECK_FAILED' || e.response.code == 'WOOCOMMERCE_ORDER_CREATION_FAILED'){
|
220 |
document.getElementById('error-message').innerHTML = "<p style='margin-top: revert;text-color: #e2401c !important;color: #e80707;'>"+e.response.message+"</p>";
|
|
|
|
|
221 |
} else {
|
222 |
document.getElementById('error-message').innerHTML = "<p style='margin-top: revert;text-color: #e2401c !important;color: #e80707;'>Something went wrong, please try again after sometime.</p>";
|
223 |
}
|
includes/api/cart.php
CHANGED
@@ -11,21 +11,32 @@ function create1ccCart($orderId)
|
|
11 |
global $woocommerce;
|
12 |
|
13 |
$order = wc_get_order($orderId);
|
|
|
|
|
|
|
|
|
|
|
14 |
|
|
|
15 |
if ($order && $order->get_item_count() > 0) {
|
16 |
foreach ($order->get_items() as $item_id => $item) {
|
17 |
-
$productId
|
18 |
-
$variationId
|
19 |
-
$quantity
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
-
WC()->cart->add_to_cart(
|
23 |
-
$productId,
|
24 |
-
$quantity,
|
25 |
-
$variationId,
|
26 |
-
[],
|
27 |
-
$customData
|
28 |
-
);
|
29 |
}
|
30 |
|
31 |
return true;
|
11 |
global $woocommerce;
|
12 |
|
13 |
$order = wc_get_order($orderId);
|
14 |
+
try {
|
15 |
+
rzpLogInfo('# order count');
|
16 |
+
rzpLogInfo($order->get_item_count());
|
17 |
+
} catch (\Exception $e) {
|
18 |
+
}
|
19 |
|
20 |
+
$variationAttributes = [];
|
21 |
if ($order && $order->get_item_count() > 0) {
|
22 |
foreach ($order->get_items() as $item_id => $item) {
|
23 |
+
$productId = $item->get_product_id();
|
24 |
+
$variationId = $item->get_variation_id();
|
25 |
+
$quantity = $item->get_quantity();
|
26 |
+
|
27 |
+
$customData['item_id'] = $item_id;
|
28 |
+
$product = $item->get_product();
|
29 |
+
if ($product->is_type('variation')) {
|
30 |
+
$variation_attributes = $product->get_variation_attributes();
|
31 |
+
foreach ($variation_attributes as $attribute_taxonomy => $term_slug) {
|
32 |
+
$taxonomy = str_replace('attribute_', '', $attribute_taxonomy);
|
33 |
+
$value = wc_get_order_item_meta($item_id, $taxonomy, true);
|
34 |
+
$variationAttributes[$attribute_taxonomy] = $value;
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
$woocommerce->cart->add_to_cart($productId, $quantity, $variationId, $variationAttributes, $customData);
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
}
|
41 |
|
42 |
return true;
|
includes/api/order.php
CHANGED
@@ -91,6 +91,10 @@ function createWcOrder(WP_REST_Request $request)
|
|
91 |
if ($orderIdFromHash == null) {
|
92 |
$checkout = WC()->checkout();
|
93 |
$orderId = $checkout->create_order(array());
|
|
|
|
|
|
|
|
|
94 |
} else {
|
95 |
$existingOrder = wc_get_order($orderIdFromHash);
|
96 |
$existingOrder->calculate_totals();
|
@@ -99,6 +103,10 @@ function createWcOrder(WP_REST_Request $request)
|
|
99 |
$woocommerce->session->__unset(RZP_1CC_CART_HASH . $cartHash);
|
100 |
$checkout = WC()->checkout();
|
101 |
$orderId = $checkout->create_order(array());
|
|
|
|
|
|
|
|
|
102 |
} else {
|
103 |
$orderId = $woocommerce->session->get(RZP_1CC_CART_HASH . $cartHash);
|
104 |
}
|
@@ -106,18 +114,19 @@ function createWcOrder(WP_REST_Request $request)
|
|
106 |
|
107 |
$order = wc_get_order($orderId);
|
108 |
|
109 |
-
|
110 |
-
|
|
|
111 |
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
|
|
116 |
}
|
117 |
-
}
|
118 |
|
119 |
-
|
120 |
-
|
121 |
update_post_meta($orderId, 'is_magic_checkout_order', 'yes');
|
122 |
|
123 |
$minCartAmount1cc = !empty(get_option('woocommerce_razorpay_settings')['1cc_min_cart_amount']) ? get_option('woocommerce_razorpay_settings')['1cc_min_cart_amount'] : 0;
|
@@ -215,7 +224,7 @@ function createWcOrder(WP_REST_Request $request)
|
|
215 |
return new WP_REST_Response($response, 200);
|
216 |
} else {
|
217 |
$response['status'] = false;
|
218 |
-
$response['message'] =
|
219 |
$response['code'] = 'WOOCOMMERCE_ORDER_CREATION_FAILED';
|
220 |
|
221 |
$logObj['response'] = $response;
|
91 |
if ($orderIdFromHash == null) {
|
92 |
$checkout = WC()->checkout();
|
93 |
$orderId = $checkout->create_order(array());
|
94 |
+
|
95 |
+
if (is_wp_error($orderId)) {
|
96 |
+
$checkout_error = $orderId->get_error_message();
|
97 |
+
}
|
98 |
} else {
|
99 |
$existingOrder = wc_get_order($orderIdFromHash);
|
100 |
$existingOrder->calculate_totals();
|
103 |
$woocommerce->session->__unset(RZP_1CC_CART_HASH . $cartHash);
|
104 |
$checkout = WC()->checkout();
|
105 |
$orderId = $checkout->create_order(array());
|
106 |
+
|
107 |
+
if (is_wp_error($orderId)) {
|
108 |
+
$checkout_error = $orderId->get_error_message();
|
109 |
+
}
|
110 |
} else {
|
111 |
$orderId = $woocommerce->session->get(RZP_1CC_CART_HASH . $cartHash);
|
112 |
}
|
114 |
|
115 |
$order = wc_get_order($orderId);
|
116 |
|
117 |
+
if ($order) {
|
118 |
+
//To remove by default shipping method added on order.
|
119 |
+
$items = (array) $order->get_items('shipping');
|
120 |
|
121 |
+
if (sizeof($items) > 0) {
|
122 |
+
// Loop through shipping items
|
123 |
+
foreach ($items as $item_id => $item) {
|
124 |
+
$order->remove_item($item_id);
|
125 |
+
}
|
126 |
}
|
|
|
127 |
|
128 |
+
$order->calculate_totals();
|
129 |
+
|
130 |
update_post_meta($orderId, 'is_magic_checkout_order', 'yes');
|
131 |
|
132 |
$minCartAmount1cc = !empty(get_option('woocommerce_razorpay_settings')['1cc_min_cart_amount']) ? get_option('woocommerce_razorpay_settings')['1cc_min_cart_amount'] : 0;
|
224 |
return new WP_REST_Response($response, 200);
|
225 |
} else {
|
226 |
$response['status'] = false;
|
227 |
+
$response['message'] = $checkout_error;
|
228 |
$response['code'] = 'WOOCOMMERCE_ORDER_CREATION_FAILED';
|
229 |
|
230 |
$logObj['response'] = $response;
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: razorpay
|
|
3 |
Tags: razorpay, payments, india, woocommerce, ecommerce
|
4 |
Requires at least: 3.9.2
|
5 |
Tested up to: 5.9
|
6 |
-
Stable tag: 3.0.
|
7 |
Requires PHP: 5.6
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
@@ -41,6 +41,12 @@ This is compatible with WooCommerce>=2.4, including the new 3.0 release. It has
|
|
41 |
|
42 |
== Changelog ==
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
= 3.0.0 =
|
45 |
* Added Magic Checkout feature.
|
46 |
|
3 |
Tags: razorpay, payments, india, woocommerce, ecommerce
|
4 |
Requires at least: 3.9.2
|
5 |
Tested up to: 5.9
|
6 |
+
Stable tag: 3.0.1
|
7 |
Requires PHP: 5.6
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
41 |
|
42 |
== Changelog ==
|
43 |
|
44 |
+
= 3.0.1 =
|
45 |
+
* Bug fix for Stock Management issue on magic checkout buy now option.
|
46 |
+
* Bug fix for Cart page checkout style issue on magic checkout.
|
47 |
+
* Optimize latency issue.
|
48 |
+
* Bug fix for PG title missing on invoice for magic checkout.
|
49 |
+
|
50 |
= 3.0.0 =
|
51 |
* Added Magic Checkout feature.
|
52 |
|
templates/rzp-cart-checkout-btn.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
<div>
|
7 |
<button
|
8 |
id="btn-1cc"
|
9 |
-
class="rzp-checkout-button button alt wc-forward"
|
10 |
type="button"
|
11 |
>PROCEED TO CHECKOUT
|
12 |
</button>
|
6 |
<div>
|
7 |
<button
|
8 |
id="btn-1cc"
|
9 |
+
class="rzp-checkout-button checkout-button button alt wc-forward"
|
10 |
type="button"
|
11 |
>PROCEED TO CHECKOUT
|
12 |
</button>
|
woo-razorpay.php
CHANGED
@@ -3,10 +3,10 @@
|
|
3 |
* Plugin Name: Razorpay for WooCommerce
|
4 |
* Plugin URI: https://razorpay.com
|
5 |
* Description: Razorpay Payment Gateway Integration for WooCommerce
|
6 |
-
* Version: 3.0.
|
7 |
-
* Stable tag: 3.0.
|
8 |
* Author: Team Razorpay
|
9 |
-
* WC tested up to: 6.2.
|
10 |
* Author URI: https://razorpay.com
|
11 |
*/
|
12 |
|
@@ -1504,6 +1504,7 @@ EOT;
|
|
1504 |
|
1505 |
//update payment method title
|
1506 |
$order->set_payment_method($payment_method);
|
|
|
1507 |
$order->save();
|
1508 |
|
1509 |
if (($paymentDoneBy === 'cod') && isset($razorpayData['cod_fee']) == true)
|
@@ -1783,8 +1784,6 @@ function enqueueScriptsFor1cc()
|
|
1783 |
wp_enqueue_script('btn_1cc_checkout');
|
1784 |
}
|
1785 |
|
1786 |
-
add_action('woocommerce_cart_updated', 'enqueueScriptsFor1cc', 10);
|
1787 |
-
|
1788 |
//To add 1CC button on cart page.
|
1789 |
add_action( 'woocommerce_proceed_to_checkout', 'addCheckoutButton');
|
1790 |
|
@@ -1893,7 +1892,7 @@ function disable_coupon_field_on_cart($enabled)
|
|
1893 |
|
1894 |
if(is1ccEnabled())
|
1895 |
{
|
1896 |
-
add_filter(
|
|
|
|
|
1897 |
}
|
1898 |
-
|
1899 |
-
add_filter('woocommerce_order_needs_shipping_address', '__return_true');
|
3 |
* Plugin Name: Razorpay for WooCommerce
|
4 |
* Plugin URI: https://razorpay.com
|
5 |
* Description: Razorpay Payment Gateway Integration for WooCommerce
|
6 |
+
* Version: 3.0.1
|
7 |
+
* Stable tag: 3.0.1
|
8 |
* Author: Team Razorpay
|
9 |
+
* WC tested up to: 6.2.1
|
10 |
* Author URI: https://razorpay.com
|
11 |
*/
|
12 |
|
1504 |
|
1505 |
//update payment method title
|
1506 |
$order->set_payment_method($payment_method);
|
1507 |
+
$order->set_payment_method_title($this->title);
|
1508 |
$order->save();
|
1509 |
|
1510 |
if (($paymentDoneBy === 'cod') && isset($razorpayData['cod_fee']) == true)
|
1784 |
wp_enqueue_script('btn_1cc_checkout');
|
1785 |
}
|
1786 |
|
|
|
|
|
1787 |
//To add 1CC button on cart page.
|
1788 |
add_action( 'woocommerce_proceed_to_checkout', 'addCheckoutButton');
|
1789 |
|
1892 |
|
1893 |
if(is1ccEnabled())
|
1894 |
{
|
1895 |
+
add_filter('woocommerce_coupons_enabled', 'disable_coupon_field_on_cart');
|
1896 |
+
add_action('woocommerce_cart_updated', 'enqueueScriptsFor1cc', 10);
|
1897 |
+
add_filter('woocommerce_order_needs_shipping_address', '__return_true');
|
1898 |
}
|
|
|
|