Skip to content

Commit

Permalink
Free Orders where shipping is all that needs to be paid, ref #361
Browse files Browse the repository at this point in the history
  • Loading branch information
kcppdevelopers committed Mar 13, 2017
1 parent d7fc62c commit 6e6d171
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions classes/wc-gateway-paypal-express-angelleye.php
Original file line number Diff line number Diff line change
Expand Up @@ -677,16 +677,17 @@ public static function angelleye_get_paypalimage() {

public function handle_wc_api() {
try {
require_once( PAYPAL_FOR_WOOCOMMERCE_PLUGIN_DIR . '/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-request-angelleye.php' );
$paypal_express_request = new WC_Gateway_PayPal_Express_Request_AngellEYE($this);
if (!isset($_GET['pp_action'])) {
return;
}
if (WC()->cart->cart_contents_total <= 0) {
if (WC()->cart->cart_contents_total <= 0 && WC()->cart->total <= 0) {
wc_add_notice(__('your order amount is zero, We were unable to process your order, please try again.', 'paypal-for-woocommerce'), 'error');
wp_redirect(WC()->cart->get_cart_url());
$paypal_express_request->angelleye_redirect();
exit;
}
require_once( PAYPAL_FOR_WOOCOMMERCE_PLUGIN_DIR . '/angelleye-includes/express-checkout/class-wc-gateway-paypal-express-request-angelleye.php' );
$paypal_express_request = new WC_Gateway_PayPal_Express_Request_AngellEYE($this);

switch ($_GET['pp_action']) {
case 'set_express_checkout':
if ((isset($_POST['wc-paypal_express-new-payment-method']) && $_POST['wc-paypal_express-new-payment-method'] = 'on') || ( isset($_GET['ec_save_to_account']) && $_GET['ec_save_to_account'] == true)) {
Expand Down

6 comments on commit 6e6d171

@angelleye
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kcppdevelopers Looks like we're still adding a WC notice about the amount being zero and unable to process even though we're redirecting and allowing the order..??

@kcppdevelopers
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@angelleye I have tested all the payment method and now it's working fine.

@angelleye
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kcppdevelopers I understand the functionality looks to be working fine, but is it still leaving an admin notice somewhere about the order amount being zero? I'm referring to 6e6d171#diff-0d4905591d4c6c2d8a88434d34bbfaffR686

@kcppdevelopers
Copy link
Contributor Author

@kcppdevelopers kcppdevelopers commented on 6e6d171 Apr 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@angelleye Logically it's true because shipping cost must be added in the WC()->cart->total variable.

@angelleye
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kcppdevelopers If the line items come to $0 but shipping is $5, and you're adding $5 to the cart -> total, then how is the order total zero? They wouldn't need to try again because of an unprocessed order. The whole point is that we're allowing these to go through so that people can pay for just the shipping.

So I still don't see how this log message makes sense..??

@kcppdevelopers
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I am not adding shipping to cart total. cart->total = shipping + tax + product total - discount.
cart->total = 0 means shipping is disable or 0 amount.

Please sign in to comment.