Changeset 2833784
- Timestamp:
- 12/14/2022 01:50:48 PM (3 years ago)
- Location:
- doshii/trunk
- Files:
-
- 6 edited
-
README.txt (modified) (2 diffs)
-
doshii_function.php (modified) (1 diff)
-
include/woo-doshii-initialise.php (modified) (1 diff)
-
include/woo-doshii-product-sync.php (modified) (1 diff)
-
include/woo-order-api.php (modified) (2 diffs)
-
include/woo-order-status.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
doshii/trunk/README.txt
r2826771 r2833784 5 5 Requires at least: 4.7 6 6 Tested up to: 5.8.0 7 Stable tag: 2.5. 37 Stable tag: 2.5.4 8 8 Requires PHP: 7.0 9 9 License: GPLv2 or later … … 59 59 60 60 == Changelog == 61 62 = 2.5.4 = 63 64 Removed coupons from surcounts 61 65 62 66 = 2.5.3 = -
doshii/trunk/doshii_function.php
r2826771 r2833784 7 7 Author URI: https://www.doshii.io 8 8 Contributors: 9 Version: 2.5. 39 Version: 2.5.4 10 10 */ 11 11 -
doshii/trunk/include/woo-doshii-initialise.php
r2826771 r2833784 40 40 'x-doshii-location-id' => $locationId.'', 41 41 'content-Type' => 'application/json', 42 'x-doshii-writeout' => 'WooCommerce 2.5. 3',42 'x-doshii-writeout' => 'WooCommerce 2.5.4', 43 43 ); 44 44 -
doshii/trunk/include/woo-doshii-product-sync.php
r2826771 r2833784 48 48 'x-doshii-location-id' => $locationId.'', 49 49 'content-Type' => 'application/json', 50 'x-doshii-writeout' => 'WooCommerce 2.5. 3',50 'x-doshii-writeout' => 'WooCommerce 2.5.4', 51 51 ) 52 52 )); -
doshii/trunk/include/woo-order-api.php
r2826771 r2833784 142 142 'value' => $taxTotal 143 143 ]); 144 145 foreach ( $order->get_items( 'coupon' ) as $coupon ) {146 $couponCode = $coupon->get_code();147 $amount = $coupon->get_discount();148 $couponData = $coupon->get_meta('coupon_data');149 $couponType = $couponData['discount_type'];150 151 $couponTypeLabel = ucwords(str_replace('_', ' ', $couponType));152 153 // valid types: fixed_cart, fixed_product, percent154 $surcountType = $couponType == 'percent' ? 'percentage' : 'absolute';155 156 if (!empty($amount) && $amount > 0) {157 $surcountValue = -doshii_to_cents($amount);158 if ($surcountType === 'percentage') {159 $amount = -$amount; // negative percent160 $orderSubtotal = $order->get_subtotal(); // we need to calculate the coupon discount based on order subtotal161 $surcountValue = -doshii_to_cents($orderSubtotal * ($amount / 100)); // percentage -> amount = %, value = $162 } else {163 $amount = $surcountValue; // absolute -> amount = value164 }165 array_push($surcounts, (object)[166 'name' => "$couponTypeLabel Coupon: $couponCode",167 'amount' => $amount,168 'type' => $surcountType,169 'value' => $surcountValue170 ]);171 }172 }173 144 174 145 $fullname = $first_name.' '.$last_name; … … 708 679 'accept' => 'application/json', 709 680 'Accept-encoding' => 'gzip', 710 'x-doshii-writeout' => 'WooCommerce 2.5. 3',681 'x-doshii-writeout' => 'WooCommerce 2.5.4', 711 682 ), 712 683 'body' => json_encode($doshiiOrderPayload) -
doshii/trunk/include/woo-order-status.php
r2826771 r2833784 39 39 'x-doshii-location-id' => $doshii_options['location_id'].'', 40 40 'content-Type' => 'application/json', 41 'x-doshii-writeout' => 'WooCommerce 2.5. 3',41 'x-doshii-writeout' => 'WooCommerce 2.5.4', 42 42 ) 43 43 ));
Note: See TracChangeset
for help on using the changeset viewer.