From 375d973128ea214cb74c1748f6b3820da744511d Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Mon, 23 Apr 2012 15:02:48 +0100 Subject: [PATCH] When sending the order as a whole to paypal, send the shipping separately.. Closes #976. --- classes/class-wc-order.php | 5 +++++ classes/gateways/class-wc-paypal.php | 13 ++++++++----- readme.txt | 3 ++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/classes/class-wc-order.php b/classes/class-wc-order.php index a02ad678245..1728cccfc2b 100644 --- a/classes/class-wc-order.php +++ b/classes/class-wc-order.php @@ -291,6 +291,11 @@ class WC_Order { return $this->order_shipping; } + /** Gets shipping tax amount */ + function get_shipping_tax() { + return $this->order_shipping_tax; + } + /** Gets order total */ function get_order_total() { return $this->order_total; diff --git a/classes/gateways/class-wc-paypal.php b/classes/gateways/class-wc-paypal.php index acfb7abaeb1..a554740c57e 100644 --- a/classes/gateways/class-wc-paypal.php +++ b/classes/gateways/class-wc-paypal.php @@ -234,6 +234,7 @@ class WC_Paypal extends WC_Payment_Gateway { // Payment Info 'invoice' => $order->order_key + ), $phone_args ); @@ -258,7 +259,7 @@ class WC_Paypal extends WC_Payment_Gateway { $paypal_args['no_shipping'] = 1; } - // If prices include tax or have order discounts, send the whole order + // If prices include tax or have order discounts, send the whole order as a single item if ( get_option('woocommerce_prices_include_tax')=='yes' || $order->get_order_discount() > 0 ) : // Discount @@ -273,14 +274,16 @@ class WC_Paypal extends WC_Payment_Gateway { $paypal_args['item_name_1'] = sprintf( __('Order %s' , 'woocommerce'), $order->get_order_number() ) . " - " . implode(', ', $item_names); $paypal_args['quantity_1'] = 1; - $paypal_args['amount_1'] = number_format($order->get_order_total() - $order->get_shipping() + $order->get_order_discount(), 2, '.', ''); + $paypal_args['amount_1'] = number_format($order->get_order_total() - $order->get_shipping() - $order->get_shipping_tax() + $order->get_order_discount(), 2, '.', ''); // Shipping Cost - if ($order->get_shipping()>0) : + $paypal_args['shipping_1'] = number_format( $order->get_shipping() + $order->get_shipping_tax() , 2, '.', '' ); + + /*if ( $order->get_shipping() > 0 ) : $paypal_args['item_name_2'] = __('Shipping via', 'woocommerce') . ' ' . ucwords($order->shipping_method_title); $paypal_args['quantity_2'] = '1'; $paypal_args['amount_2'] = number_format($order->get_shipping(), 2, '.', ''); - endif; + endif;*/ else : @@ -311,7 +314,7 @@ class WC_Paypal extends WC_Payment_Gateway { endif; endforeach; endif; - // Shipping Cost + // Shipping Cost item - paypal only allows shipping per item, we want to send shipping for the order if ($order->get_shipping()>0) : $item_loop++; $paypal_args['item_name_'.$item_loop] = __('Shipping via', 'woocommerce') . ucwords($order->shipping_method_title); diff --git a/readme.txt b/readme.txt index 91d466a93a7..591572152ed 100644 --- a/readme.txt +++ b/readme.txt @@ -154,7 +154,8 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc * Tweak - Changed category and tag link to filter product list in admin panel * Tweak - Removed product 'exists' variable in favour of the exists() method. Tweaked exist method to look for ID in DB. * Tweak - Only use rm=2 for paypal when SSL is enabled, to avoid security warnings when returning to the site. -* Tweak - Show sku in stock reports +* Tweak - Show sku in stock reports. +* Tweak - When sending the order as a whole to paypal, send the shipping separately. * Fix - Replacing use of deprecated function get_current_theme() with wp_get_theme() * Fix - Body classes now correct for WordPress themes with non alphanumeric characters * Fix - PayPal http_build_query & -> & on some PHP 5.3 servers