Changeset 3318023
- Timestamp:
- 06/26/2025 07:02:35 AM (9 months ago)
- Location:
- simpler-checkout
- Files:
-
- 2 added
- 36 edited
- 1 copied
-
tags/1.1.9 (copied) (copied from simpler-checkout/trunk)
-
tags/1.1.9/README.txt (modified) (2 diffs)
-
tags/1.1.9/includes/Compatibility/cod.php (modified) (4 diffs)
-
tags/1.1.9/includes/Compatibility/multi-currency.php (added)
-
tags/1.1.9/includes/Http/Controllers/OrderController.php (modified) (5 diffs)
-
tags/1.1.9/includes/Http/Controllers/QuotationController.php (modified) (6 diffs)
-
tags/1.1.9/includes/Http/Payloads/QuotationResponse.php (modified) (6 diffs)
-
tags/1.1.9/includes/Models/OrderRequest.php (modified) (1 diff)
-
tags/1.1.9/includes/Models/Quotation.php (modified) (2 diffs)
-
tags/1.1.9/includes/Models/QuotationRequest.php (modified) (2 diffs)
-
tags/1.1.9/includes/Services/CartHelper.php (modified) (1 diff)
-
tags/1.1.9/includes/Services/OrderService.php (modified) (4 diffs)
-
tags/1.1.9/includes/Services/QuotationService.php (modified) (9 diffs)
-
tags/1.1.9/includes/compat.php (modified) (1 diff)
-
tags/1.1.9/includes/constants.php (modified) (1 diff)
-
tags/1.1.9/simpler.php (modified) (1 diff)
-
tags/1.1.9/vendor/autoload.php (modified) (1 diff)
-
tags/1.1.9/vendor/composer/autoload_real.php (modified) (3 diffs)
-
tags/1.1.9/vendor/composer/autoload_static.php (modified) (2 diffs)
-
tags/1.1.9/vendor/composer/installed.php (modified) (2 diffs)
-
trunk/README.txt (modified) (2 diffs)
-
trunk/includes/Compatibility/cod.php (modified) (4 diffs)
-
trunk/includes/Compatibility/multi-currency.php (added)
-
trunk/includes/Http/Controllers/OrderController.php (modified) (5 diffs)
-
trunk/includes/Http/Controllers/QuotationController.php (modified) (6 diffs)
-
trunk/includes/Http/Payloads/QuotationResponse.php (modified) (6 diffs)
-
trunk/includes/Models/OrderRequest.php (modified) (1 diff)
-
trunk/includes/Models/Quotation.php (modified) (2 diffs)
-
trunk/includes/Models/QuotationRequest.php (modified) (2 diffs)
-
trunk/includes/Services/CartHelper.php (modified) (1 diff)
-
trunk/includes/Services/OrderService.php (modified) (4 diffs)
-
trunk/includes/Services/QuotationService.php (modified) (9 diffs)
-
trunk/includes/compat.php (modified) (1 diff)
-
trunk/includes/constants.php (modified) (1 diff)
-
trunk/simpler.php (modified) (1 diff)
-
trunk/vendor/autoload.php (modified) (1 diff)
-
trunk/vendor/composer/autoload_real.php (modified) (3 diffs)
-
trunk/vendor/composer/autoload_static.php (modified) (2 diffs)
-
trunk/vendor/composer/installed.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
simpler-checkout/tags/1.1.9/README.txt
r3292379 r3318023 5 5 Tested up to: 6.5 6 6 Requires PHP: 7.0 7 Stable tag: 1.1. 87 Stable tag: 1.1.9 8 8 License: GPLv3 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 35 35 36 36 == Changelog == 37 38 == 1.1.9 39 Compat: [WPML Multicurrency](https://wordpress.org/plugins/woocommerce-multilingual/) 40 Compat: [Pre-Orders for WooCommerce](https://wordpress.org/plugins/pre-orders-for-woocommerce/) 37 41 38 42 == 1.1.8 -
simpler-checkout/tags/1.1.9/includes/Compatibility/cod.php
r3290493 r3318023 5 5 use Simpler\Models\PaymentMethod; 6 6 use Simpler\Models\Quotation; 7 8 function get_smart_cod_fee($paymentMethod) 9 { 10 if (!defined('DOING_AJAX')) 11 define('DOING_AJAX', true); 12 $smartCod = new \WC_Smart_COD_Public('wc-smart-cod'); 13 $smartCod->init_wsc_settings(); 14 if (!$smartCod->has_cod_available()) { 15 throw new Exception('SmartCOD is not available'); 16 } 17 $codCost = $smartCod->apply_smart_cod_fees(WC()->cart, false); 18 if (isset($paymentMethod->settings['extra_fee_tax']) && $paymentMethod->settings['extra_fee_tax'] == 'enable') { 19 $taxes = \wc_array_merge_recursive_numeric([], \WC_Tax::calc_tax($codCost, \WC_Tax::get_rates(''), false)); 20 if (!empty($taxes)) { 21 $codCost += array_sum($taxes); 22 } 23 } 24 return $codCost; 25 } 7 26 8 27 /** … … 20 39 } 21 40 22 if (!defined('DOING_AJAX'))23 define('DOING_AJAX', true);24 41 $availablePaymentMethods = WC()->payment_gateways->get_available_payment_gateways(); 25 42 … … 27 44 if (isset($availablePaymentMethods['cod'])) { 28 45 if ($availablePaymentMethods['cod'] instanceof \WC_Smart_COD_Admin) { 29 $smartCod = new \WC_Smart_COD_Public('wc-smart-cod');30 $smartCod->init_wsc_settings();31 if (!$smartCod->has_cod_available()) {46 try { 47 $codCost = get_smart_cod_fee($availablePaymentMethods['cod']); 48 } catch (Exception $err) { 32 49 return $paymentMethods; 33 }34 $codCost = $smartCod->apply_smart_cod_fees(WC()->cart, false);35 if (isset($availablePaymentMethods['cod']->settings['extra_fee_tax']) && $availablePaymentMethods['cod']->settings['extra_fee_tax'] == 'enable') {36 $taxes = \wc_array_merge_recursive_numeric([], \WC_Tax::calc_tax($codCost, \WC_Tax::get_rates(''), false));37 if (!empty($taxes)) {38 $codCost += array_sum($taxes);39 }40 50 } 41 51 } else if (class_exists('Pay4Pay')) { … … 78 88 79 89 if ($paymentGateway instanceof \Wc_Smart_Cod_Admin) { 80 $closures[] = function () use ($paymentGateway, $paymentMethod) { 81 WC()->cart->add_fee( 82 $paymentMethod->getName() ?: $paymentGateway->title, 83 Money::from_cents($paymentMethod->getTotalCents()) 84 ); 85 }; 90 $codCost = 0; 91 try { 92 $codCost = get_smart_cod_fee($paymentGateway); 93 } catch (Exception $err) { 94 return $closures; 95 } 96 // adding fees might be unnecessary... smart cod adds the fee automatically, 97 // but it needs to be initialized by get_smart_cod_fee() 98 99 // $codCost = apply_filters('simplerwc_cod_cost', $codCost); 100 // $closures[] = function () use ($codCost, $paymentGateway, $paymentMethod) { 101 // WC()->cart->add_fee( 102 // $paymentMethod->getName() ?: $paymentGateway->title, 103 // $codCost 104 // ); 105 // }; 86 106 } 87 107 return $closures; -
simpler-checkout/tags/1.1.9/includes/Http/Controllers/OrderController.php
r3041307 r3318023 9 9 use WP_REST_Response; 10 10 11 12 11 class OrderController extends Controller 13 12 { 13 protected $namespace = 'wc/simpler/v2'; 14 14 15 protected $namespace = 'wc/simpler/v2';16 15 /** 17 16 * Route name. … … 27 26 */ 28 27 protected $method = 'POST'; 29 /** 30 * @var UserService 31 */ 28 29 /** @var UserService */ 32 30 private $userService; 33 /** 34 * @var OrderService 35 */ 31 /** @var OrderService */ 36 32 private $orderService; 37 33 … … 39 35 { 40 36 parent::__construct(); 41 $this->userService = $userService ?: newUserService();37 $this->userService = $userService ?: new UserService(); 42 38 $this->orderService = $orderService ?: new OrderService(); 43 39 } … … 54 50 return new WP_REST_Response(json_encode($validation), 422); 55 51 } 56 57 52 $order_request = new OrderRequest( 58 53 User::from_json($body['user']), … … 82 77 83 78 $response = [ 84 'user_id' => strval($user_id),79 'user_id' => strval($user_id), 85 80 'order_id' => strval(apply_filters('simplerwc_order_id', $order->get_id(), $order)) 86 81 ]; -
simpler-checkout/tags/1.1.9/includes/Http/Controllers/QuotationController.php
r3272319 r3318023 13 13 { 14 14 protected $namespace = 'wc/simpler/v2'; 15 15 16 /** 16 17 * Route name. … … 26 27 */ 27 28 protected $method = 'POST'; 28 /** 29 * @var QuotationService 30 */ 29 30 /** @var QuotationService */ 31 31 protected $quotationService; 32 /** 33 * @var WP_REST_Request 34 */ 32 /** @var WP_REST_Request */ 35 33 private $request; 36 34 … … 47 45 { 48 46 $this->request = $request; 49 $validation = \rest_validate_value_from_schema($this->request->get_json_params(), QuotationSchema::SCHEMA);47 $validation = \rest_validate_value_from_schema($this->request->get_json_params(), QuotationSchema::SCHEMA); 50 48 if (\is_wp_error($validation)) { 51 49 return new WP_REST_Response(json_encode($validation), 422); … … 57 55 return new WP_REST_Response( 58 56 [ 59 'code' => $e instanceof BaseException ? $e->get_error_code() : $e->getCode(),57 'code' => $e instanceof BaseException ? $e->get_error_code() : $e->getCode(), 60 58 'message' => 'Failed to quote cart', 61 'error' => $e->getMessage(),59 'error' => $e->getMessage(), 62 60 ], 63 61 400 64 62 ); 65 63 } 66 67 64 return new WP_REST_Response((new QuotationResponse($quotations))->to_array()); 68 65 } … … 77 74 { 78 75 $items = []; 79 $body = $this->request->get_json_params();76 $body = $this->request->get_json_params(); 80 77 foreach ($body['items'] as $item) { 81 78 $items[] = CartItem::from_json($item); … … 83 80 84 81 $request = new QuotationRequest($items); 85 $request->set_coupon_code($body['coupon'] ?? '') 82 $request 83 ->set_currency($body['currency'] ?? '') 84 ->set_coupon_code($body['coupon'] ?? '') 86 85 ->set_user_email($body['email'] ?? '') 87 86 ->set_shipping_address(isset($body['shipto']) ? Address::from_quotation_json($body['shipto']) : null); -
simpler-checkout/tags/1.1.9/includes/Http/Payloads/QuotationResponse.php
r3272319 r3318023 9 9 { 10 10 private $response = []; 11 /** 12 * @var Quotation[] 13 */ 11 /** @var Quotation[] */ 14 12 private $quotations; 15 13 … … 25 23 foreach ($this->quotations as $quotation) { 26 24 $response = [ 27 'products' => $this->get_products_response($quotation), 28 'shipping' => $quotation->get_shipping_rate() ? $this->get_shipping_rate_response($quotation) 25 'products' => $this->get_products_response($quotation), 26 'shipping' => $quotation->get_shipping_rate() 27 ? $this->get_shipping_rate_response($quotation) 29 28 : null, 30 29 'discount_cents' => $quotation->get_discount_cents(), 31 'total_cents' => $quotation->get_total_cents(),32 'fees' => $this->get_fees_response($quotation),30 'total_cents' => $quotation->get_total_cents(), 31 'fees' => $this->get_fees_response($quotation), 33 32 ]; 34 33 35 if ($paymentMethods = $this->get_payment_methods_response($quotation)){ 34 if ($currency = $quotation->get_currency()) { 35 $response['currency'] = $currency; 36 } 37 38 if ($paymentMethods = $this->get_payment_methods_response($quotation)) { 36 39 $response['payment_methods'] = $paymentMethods; 37 40 } 38 39 if ($addons = $this->get_addons_response($quotation)) {41 42 if ($addons = $this->get_addons_response($quotation)) { 40 43 $response['addons'] = $addons; 41 44 } … … 55 58 { 56 59 return [ 57 'id' => $quotation->get_shipping_rate()->get_id(),58 'method_id' => $quotation->get_shipping_rate()->get_method_id(),59 'label' => wc_clean($quotation->get_shipping_rate()->get_label()),60 'cost_cents' => $quotation->get_shipping_cents(),61 'tax_cents' => $quotation->get_shipping_tax_cents(),60 'id' => $quotation->get_shipping_rate()->get_id(), 61 'method_id' => $quotation->get_shipping_rate()->get_method_id(), 62 'label' => wc_clean($quotation->get_shipping_rate()->get_label()), 63 'cost_cents' => $quotation->get_shipping_cents(), 64 'tax_cents' => $quotation->get_shipping_tax_cents(), 62 65 'instance_id' => $quotation->get_shipping_rate()->get_instance_id(), 63 66 ]; … … 77 80 foreach ($quotation->get_products() as $product) { 78 81 $data = [ 79 'id' => (string)$product->get_product_id(),80 'quantity' => $product->get_quantity(),82 'id' => (string) $product->get_product_id(), 83 'quantity' => $product->get_quantity(), 81 84 'subtotal_net_cents' => Money::to_cents($product->get_subtotal_net_cost()), 82 85 'subtotal_tax_cents' => Money::to_cents($product->get_subtotal_tax_cost()), 83 'subtotal_cents' => Money::to_cents($product->get_subtotal_cost()),84 'cost_net_cents' => Money::to_cents($product->get_total_net_cost()),85 'cost_tax_cents' => Money::to_cents($product->get_total_tax_cost()),86 'cost_cents' => Money::to_cents($product->get_total_cost()),86 'subtotal_cents' => Money::to_cents($product->get_subtotal_cost()), 87 'cost_net_cents' => Money::to_cents($product->get_total_net_cost()), 88 'cost_tax_cents' => Money::to_cents($product->get_total_tax_cost()), 89 'cost_cents' => Money::to_cents($product->get_total_cost()), 87 90 ]; 88 91 89 if ( !empty($product->get_attributes())) {92 if (!empty($product->get_attributes())) { 90 93 foreach ($product->get_attributes() as $attribute) { 91 94 $data['attributes'][] = ['key' => $attribute->get_key(), 'value' => $attribute->get_value()]; … … 112 115 foreach ($quotation->get_fees() as $fee) { 113 116 $response[] = [ 114 'id' => $fee->get_id(),115 'title' => $fee->get_name(),117 'id' => $fee->get_id(), 118 'title' => $fee->get_name(), 116 119 'cost_cents' => Money::to_cents($fee->get_total() + $fee->get_tax()), 117 120 ]; … … 132 135 foreach ($quotation->get_payment_methods() as $paymentMethod) { 133 136 $paymentMethods[] = [ 134 "id"=> $paymentMethod->getId(),135 "type"=> $paymentMethod->getType(),136 "name"=> $paymentMethod->getName(),137 "net_cents"=> $paymentMethod->getNetCents(),138 "tax_cents"=> $paymentMethod->getTaxCents(),139 "total_cents"=> $paymentMethod->getTotalCents(),137 'id' => $paymentMethod->getId(), 138 'type' => $paymentMethod->getType(), 139 'name' => $paymentMethod->getName(), 140 'net_cents' => $paymentMethod->getNetCents(), 141 'tax_cents' => $paymentMethod->getTaxCents(), 142 'total_cents' => $paymentMethod->getTotalCents(), 140 143 ]; 141 144 } -
simpler-checkout/tags/1.1.9/includes/Models/OrderRequest.php
r2972503 r3318023 5 5 final class OrderRequest 6 6 { 7 /** 8 * @var User 9 */ 7 /** @var User */ 10 8 private $user; 11 /** 12 * @var Order 13 */ 9 /** @var Order */ 14 10 private $order; 15 /** 16 * @var Address 17 */ 11 /** @var Address */ 18 12 private $shipTo; 19 /** 20 * @var InvoiceDetails | null 21 */ 13 /** @var InvoiceDetails | null */ 22 14 private $invoiceDetails; 23 15 24 16 public function __construct(User $user, Order $order, Address $shipTo = null, InvoiceDetails $invoiceDetails = null) 25 17 { 26 $this->user = $user;27 $this->order = $order;18 $this->user = $user; 19 $this->order = $order; 28 20 $this->shipTo = $shipTo; 29 21 $this->invoiceDetails = $invoiceDetails; -
simpler-checkout/tags/1.1.9/includes/Models/Quotation.php
r3272319 r3318023 7 7 class Quotation 8 8 { 9 /** 10 * @var int11 */9 /** @var string */ 10 private $currency = ''; 11 /** @var int */ 12 12 private $discountCents = 0; 13 /** 14 * @var WC_Shipping_Rate 15 */ 13 /** @var WC_Shipping_Rate */ 16 14 private $shippingRate; 17 /** 18 * @var int 19 */ 15 /** @var int */ 20 16 private $shippingCents = 0; 21 /** 22 * @var int 23 */ 17 /** @var int */ 24 18 private $shippingTaxCents = 0; 25 /** 26 * @var int 27 */ 19 /** @var int */ 28 20 private $totalCents = 0; 29 /** 30 * @var QuotedProduct[] 31 */ 21 /** @var QuotedProduct[] */ 32 22 private $products = []; 33 /** 34 * @var Fee[] 35 */ 23 /** @var Fee[] */ 36 24 private $fees = []; 37 /** 38 * @var PaymentMethod[] 39 */ 25 /** @var PaymentMethod[] */ 40 26 private $paymentMethods = []; 41 /** 42 * @var array 43 */ 27 /** @var array */ 44 28 private $addons = []; 45 29 46 30 /** 31 * @param string $currency 32 * 33 * @return Quotation 34 */ 35 public function set_currency(string $currency): Quotation 36 { 37 $this->currency = $currency; 38 39 return $this; 40 } 41 42 /** 43 * @return string 44 */ 45 public function get_currency(): string 46 { 47 return $this->currency; 48 } 49 50 /** 47 51 * @param int $discountCents 48 52 * … … 154 158 155 159 return $this; 160 } 161 162 /** 163 * @return Fee[] 164 */ 165 public function get_fees(): array 166 { 167 return $this->fees; 168 } 169 170 /** 171 * @return PaymentMethod[] 172 */ 173 public function get_payment_methods(): array 174 { 175 return $this->paymentMethods; 176 } 177 178 /** 179 * @param PaymentMethod[] $paymentMethods 180 */ 181 public function set_payment_methods(array $paymentMethods) 182 { 183 $this->paymentMethods = $paymentMethods; 184 } 185 186 /** 187 * @return array 188 */ 189 public function get_addons(): array 190 { 191 return $this->addons; 192 } 193 194 /** 195 * @param array 196 */ 197 public function set_addons(array $addons) 198 { 199 $this->addons = $addons; 200 } 156 201 } 157 158 /**159 * @return Fee[]160 */161 public function get_fees(): array162 {163 return $this->fees;164 }165 166 /**167 * @return PaymentMethod[]168 */169 public function get_payment_methods(): array170 {171 return $this->paymentMethods;172 }173 174 /**175 * @param PaymentMethod[] $paymentMethods176 */177 public function set_payment_methods(array $paymentMethods)178 {179 $this->paymentMethods = $paymentMethods;180 }181 182 /**183 * @return array184 */185 public function get_addons(): array186 {187 return $this->addons;188 }189 190 /**191 * @param array192 */193 public function set_addons(array $addons)194 {195 $this->addons = $addons;196 }197 } -
simpler-checkout/tags/1.1.9/includes/Models/QuotationRequest.php
r2825689 r3318023 5 5 class QuotationRequest 6 6 { 7 /** 8 * @var string9 */7 /** @var string */ 8 private $currency = ''; 9 /** @var string */ 10 10 private $couponCode = ''; 11 /** 12 * @var string 13 */ 11 /** @var string */ 14 12 private $userEmail = ''; 15 /** 16 * @var CartItem[] 17 */ 13 /** @var CartItem[] */ 18 14 private $items; 19 /** 20 * @var Address 21 */ 15 /** @var Address */ 22 16 private $shippingAddress; 23 24 17 25 18 public function __construct(array $items) 26 19 { 27 20 $this->items = $items; 21 } 22 23 /** 24 * @param string $currency 25 * 26 * @return QuotationRequest 27 */ 28 public function set_currency(string $currency = '') 29 { 30 $this->currency = $currency; 31 32 return $this; 28 33 } 29 34 … … 81 86 * @return string 82 87 */ 88 public function get_currency(): string 89 { 90 return $this->currency; 91 } 92 93 /** 94 * @return string 95 */ 83 96 public function get_coupon_code(): string 84 97 { -
simpler-checkout/tags/1.1.9/includes/Services/CartHelper.php
r3290493 r3318023 48 48 do_action('simplerwc_after_add_to_cart', $productAdded, $item); 49 49 } 50 51 /** 52 * @param string $currency 53 * 54 * @return void 55 */ 56 function switch_currency($currency) 57 { 58 do_action('simplerwc_switch_currency', $currency); 59 60 } 50 61 } -
simpler-checkout/tags/1.1.9/includes/Services/OrderService.php
r3292379 r3318023 12 12 private $addFeeActionClosure; 13 13 private $addFeeTaxesActionClosure; 14 private $addProductToCartException; 14 15 15 16 /** … … 28 29 wp_set_current_user($user_id); 29 30 $this->initialize_cart(); 31 32 $currency = $order_request->get_order()->get_currency(); 33 $this->switch_currency($currency); 34 30 35 WC()->customer = new \WC_Customer($user_id); 31 36 $order = new \WC_Order(0); … … 37 42 $order_request->get_order()->get_simpler_cart_id() 38 43 ); 44 45 $order->set_currency($currency); 46 $order->update_meta_data('_order_currency', $currency); 47 39 48 $paymentMethodId = $this->get_payment_method_id($order_request); 40 49 WC()->session->set('chosen_payment_method', $paymentMethodId); … … 83 92 $order->set_payment_method_title(SIMPLERWC_PAYMENT_METHOD_SLUG); 84 93 } 94 95 do_action('woocommerce_checkout_create_order', $order, []); 96 $order_id = $order->save(); 97 98 do_action('woocommerce_checkout_update_order_meta', $order_id, []); 99 85 100 $orderStatus = \apply_filters('woocommerce_default_order_status', 'wc-processing'); 86 101 if ($this->get_payment_method_type($order_request) == 'BANK_TRANSFER') { 87 102 $orderStatus = 'on-hold'; 88 103 } 104 $orderStatus = apply_filters('woocommerce_payment_complete_order_status', $orderStatus, $order_id, $order); 89 105 $order->set_status($orderStatus); 90 91 do_action('woocommerce_checkout_create_order', $order, []); 92 $order_id = $order->save(); 93 do_action('woocommerce_checkout_update_order_meta', $order_id, []); 106 $order->save(); 107 94 108 do_action('woocommerce_checkout_order_created', $order); 95 109 do_action('simplerwc_order_created', $order, $order_request); 110 96 111 if ($paymentMethodId == SIMPLERWC_PAYMENT_METHOD_SLUG) { 97 do_action('woocommerce_payment_complete', $order_id );112 do_action('woocommerce_payment_complete', $order_id, null); 98 113 } 99 114 -
simpler-checkout/tags/1.1.9/includes/Services/QuotationService.php
r3272319 r3318023 3 3 namespace Simpler\Services; 4 4 5 use Exception;6 5 use Simpler\Exceptions\{ 7 6 BaseException, … … 16 15 }; 17 16 use Simpler\Models\{Fee, Money, ProductAttribute, Quotation, QuotationRequest, QuotedProduct}; 17 use Exception; 18 18 19 19 class QuotationService 20 20 { 21 22 21 use CartHelper; 23 22 … … 26 25 */ 27 26 private $request; 27 28 28 /** 29 29 * Add product to cart exception … … 42 42 43 43 /** 44 *45 44 * @return Quotation[] 46 45 * @throws Exception … … 49 48 { 50 49 $this->init(); 51 $quotations = [];50 $quotations = []; 52 51 $this->request = $request; 52 53 if ($currency = $request->get_currency()) { 54 $this->switch_currency($currency); 55 } 53 56 54 57 if ($request->get_user_email()) { … … 57 60 wp_set_current_user($user->ID); 58 61 } else { 59 wp_set_current_user(0); // override rest api access token holder62 wp_set_current_user(0); // override rest api access token holder 60 63 } 61 64 } … … 70 73 if (WC()->cart->needs_shipping() && $this->request->get_shipping_address() !== null) { 71 74 foreach ($this->calculate_shipping_rates() as $shippingRate) { 72 $quotations[] = (new Quotation())->set_ shipping_rate($shippingRate);75 $quotations[] = (new Quotation())->set_currency($currency)->set_shipping_rate($shippingRate); 73 76 } 74 77 } 75 78 76 79 if (empty($quotations)) { 77 $quotations[] = (new Quotation()) ;80 $quotations[] = (new Quotation())->set_currency($currency); 78 81 } 79 82 … … 130 133 131 134 if (!is_null($rate)) { 132 $shippingCost += (float) $rate->get_cost();135 $shippingCost += (float) $rate->get_cost(); 133 136 $shippingTax += array_sum($rate->get_taxes()); 134 137 WC()->session->set('chosen_shipping_methods', [$rate->get_id()]); … … 192 195 $products = []; 193 196 foreach (WC()->cart->get_cart() as $lineItem) { 194 195 197 $lineItem = apply_filters('simplerwc_before_create_quoted_product', $lineItem); 196 198 -
simpler-checkout/tags/1.1.9/includes/compat.php
r3290493 r3318023 1 1 <?php 2 2 3 include_once('Compatibility/bundles.php'); 4 include_once('Compatibility/cod.php'); 5 include_once('Compatibility/free-gifts.php'); 6 include_once('Compatibility/gift-cards.php'); 7 include_once('Compatibility/gift-wrap.php'); 8 include_once('Compatibility/pickup.php'); 3 include_once ('Compatibility/bundles.php'); 4 include_once ('Compatibility/cod.php'); 5 include_once ('Compatibility/free-gifts.php'); 6 include_once ('Compatibility/gift-cards.php'); 7 include_once ('Compatibility/gift-wrap.php'); 8 include_once ('Compatibility/multi-currency.php'); 9 include_once ('Compatibility/pickup.php'); -
simpler-checkout/tags/1.1.9/includes/constants.php
r3292379 r3318023 1 1 <?php 2 2 3 const SIMPLERWC_VERSION = '1.1. 8';3 const SIMPLERWC_VERSION = '1.1.9'; 4 4 5 5 function simplerwc_get_sdk_uri() -
simpler-checkout/tags/1.1.9/simpler.php
r3292379 r3318023 8 8 * Description: Simpler Checkout lets your customers complete their purchases in seconds, with any payment method they want, in any device or browser and without a password. 9 9 * Tags: woocommerce, checkout, payments, conversion rate 10 * Version: 1.1. 810 * Version: 1.1.9 11 11 * Requires at least: 5.1 12 12 * Tested up to: 6.8.1 -
simpler-checkout/tags/1.1.9/vendor/autoload.php
r3292379 r3318023 5 5 require_once __DIR__ . '/composer/autoload_real.php'; 6 6 7 return ComposerAutoloaderInit 918f6919603832b876aace4236b51c82::getLoader();7 return ComposerAutoloaderInit239c971429cdfb6300f1f3f0c6866574::getLoader(); -
simpler-checkout/tags/1.1.9/vendor/composer/autoload_real.php
r3292379 r3318023 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit 918f6919603832b876aace4236b51c825 class ComposerAutoloaderInit239c971429cdfb6300f1f3f0c6866574 6 6 { 7 7 private static $loader; … … 25 25 require __DIR__ . '/platform_check.php'; 26 26 27 spl_autoload_register(array('ComposerAutoloaderInit 918f6919603832b876aace4236b51c82', 'loadClassLoader'), true, true);27 spl_autoload_register(array('ComposerAutoloaderInit239c971429cdfb6300f1f3f0c6866574', 'loadClassLoader'), true, true); 28 28 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); 29 spl_autoload_unregister(array('ComposerAutoloaderInit 918f6919603832b876aace4236b51c82', 'loadClassLoader'));29 spl_autoload_unregister(array('ComposerAutoloaderInit239c971429cdfb6300f1f3f0c6866574', 'loadClassLoader')); 30 30 31 31 $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); … … 33 33 require __DIR__ . '/autoload_static.php'; 34 34 35 call_user_func(\Composer\Autoload\ComposerStaticInit 918f6919603832b876aace4236b51c82::getInitializer($loader));35 call_user_func(\Composer\Autoload\ComposerStaticInit239c971429cdfb6300f1f3f0c6866574::getInitializer($loader)); 36 36 } else { 37 37 $map = require __DIR__ . '/autoload_namespaces.php'; -
simpler-checkout/tags/1.1.9/vendor/composer/autoload_static.php
r3292379 r3318023 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit 918f6919603832b876aace4236b51c827 class ComposerStaticInit239c971429cdfb6300f1f3f0c6866574 8 8 { 9 9 public static $prefixLengthsPsr4 = array ( … … 89 89 { 90 90 return \Closure::bind(function () use ($loader) { 91 $loader->prefixLengthsPsr4 = ComposerStaticInit 918f6919603832b876aace4236b51c82::$prefixLengthsPsr4;92 $loader->prefixDirsPsr4 = ComposerStaticInit 918f6919603832b876aace4236b51c82::$prefixDirsPsr4;93 $loader->classMap = ComposerStaticInit 918f6919603832b876aace4236b51c82::$classMap;91 $loader->prefixLengthsPsr4 = ComposerStaticInit239c971429cdfb6300f1f3f0c6866574::$prefixLengthsPsr4; 92 $loader->prefixDirsPsr4 = ComposerStaticInit239c971429cdfb6300f1f3f0c6866574::$prefixDirsPsr4; 93 $loader->classMap = ComposerStaticInit239c971429cdfb6300f1f3f0c6866574::$classMap; 94 94 95 95 }, null, ClassLoader::class); -
simpler-checkout/tags/1.1.9/vendor/composer/installed.php
r3292379 r3318023 1 1 <?php return array( 2 2 'root' => array( 3 'pretty_version' => '1.1. 8',4 'version' => '1.1. 8.0',3 'pretty_version' => '1.1.9', 4 'version' => '1.1.9.0', 5 5 'type' => 'wordpress-plugin', 6 6 'install_path' => __DIR__ . '/../../', 7 7 'aliases' => array(), 8 'reference' => ' c25f02a05876bbe56ae9fa3cb4d382a65c3d2159',8 'reference' => 'f3944f97bc78b3ec02b0d2dbb944ade07ddcfe7b', 9 9 'name' => 'simpler-checkout/woo', 10 10 'dev' => false, … … 12 12 'versions' => array( 13 13 'simpler-checkout/woo' => array( 14 'pretty_version' => '1.1. 8',15 'version' => '1.1. 8.0',14 'pretty_version' => '1.1.9', 15 'version' => '1.1.9.0', 16 16 'type' => 'wordpress-plugin', 17 17 'install_path' => __DIR__ . '/../../', 18 18 'aliases' => array(), 19 'reference' => ' c25f02a05876bbe56ae9fa3cb4d382a65c3d2159',19 'reference' => 'f3944f97bc78b3ec02b0d2dbb944ade07ddcfe7b', 20 20 'dev_requirement' => false, 21 21 ), -
simpler-checkout/trunk/README.txt
r3292379 r3318023 5 5 Tested up to: 6.5 6 6 Requires PHP: 7.0 7 Stable tag: 1.1. 87 Stable tag: 1.1.9 8 8 License: GPLv3 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 35 35 36 36 == Changelog == 37 38 == 1.1.9 39 Compat: [WPML Multicurrency](https://wordpress.org/plugins/woocommerce-multilingual/) 40 Compat: [Pre-Orders for WooCommerce](https://wordpress.org/plugins/pre-orders-for-woocommerce/) 37 41 38 42 == 1.1.8 -
simpler-checkout/trunk/includes/Compatibility/cod.php
r3290493 r3318023 5 5 use Simpler\Models\PaymentMethod; 6 6 use Simpler\Models\Quotation; 7 8 function get_smart_cod_fee($paymentMethod) 9 { 10 if (!defined('DOING_AJAX')) 11 define('DOING_AJAX', true); 12 $smartCod = new \WC_Smart_COD_Public('wc-smart-cod'); 13 $smartCod->init_wsc_settings(); 14 if (!$smartCod->has_cod_available()) { 15 throw new Exception('SmartCOD is not available'); 16 } 17 $codCost = $smartCod->apply_smart_cod_fees(WC()->cart, false); 18 if (isset($paymentMethod->settings['extra_fee_tax']) && $paymentMethod->settings['extra_fee_tax'] == 'enable') { 19 $taxes = \wc_array_merge_recursive_numeric([], \WC_Tax::calc_tax($codCost, \WC_Tax::get_rates(''), false)); 20 if (!empty($taxes)) { 21 $codCost += array_sum($taxes); 22 } 23 } 24 return $codCost; 25 } 7 26 8 27 /** … … 20 39 } 21 40 22 if (!defined('DOING_AJAX'))23 define('DOING_AJAX', true);24 41 $availablePaymentMethods = WC()->payment_gateways->get_available_payment_gateways(); 25 42 … … 27 44 if (isset($availablePaymentMethods['cod'])) { 28 45 if ($availablePaymentMethods['cod'] instanceof \WC_Smart_COD_Admin) { 29 $smartCod = new \WC_Smart_COD_Public('wc-smart-cod');30 $smartCod->init_wsc_settings();31 if (!$smartCod->has_cod_available()) {46 try { 47 $codCost = get_smart_cod_fee($availablePaymentMethods['cod']); 48 } catch (Exception $err) { 32 49 return $paymentMethods; 33 }34 $codCost = $smartCod->apply_smart_cod_fees(WC()->cart, false);35 if (isset($availablePaymentMethods['cod']->settings['extra_fee_tax']) && $availablePaymentMethods['cod']->settings['extra_fee_tax'] == 'enable') {36 $taxes = \wc_array_merge_recursive_numeric([], \WC_Tax::calc_tax($codCost, \WC_Tax::get_rates(''), false));37 if (!empty($taxes)) {38 $codCost += array_sum($taxes);39 }40 50 } 41 51 } else if (class_exists('Pay4Pay')) { … … 78 88 79 89 if ($paymentGateway instanceof \Wc_Smart_Cod_Admin) { 80 $closures[] = function () use ($paymentGateway, $paymentMethod) { 81 WC()->cart->add_fee( 82 $paymentMethod->getName() ?: $paymentGateway->title, 83 Money::from_cents($paymentMethod->getTotalCents()) 84 ); 85 }; 90 $codCost = 0; 91 try { 92 $codCost = get_smart_cod_fee($paymentGateway); 93 } catch (Exception $err) { 94 return $closures; 95 } 96 // adding fees might be unnecessary... smart cod adds the fee automatically, 97 // but it needs to be initialized by get_smart_cod_fee() 98 99 // $codCost = apply_filters('simplerwc_cod_cost', $codCost); 100 // $closures[] = function () use ($codCost, $paymentGateway, $paymentMethod) { 101 // WC()->cart->add_fee( 102 // $paymentMethod->getName() ?: $paymentGateway->title, 103 // $codCost 104 // ); 105 // }; 86 106 } 87 107 return $closures; -
simpler-checkout/trunk/includes/Http/Controllers/OrderController.php
r3041307 r3318023 9 9 use WP_REST_Response; 10 10 11 12 11 class OrderController extends Controller 13 12 { 13 protected $namespace = 'wc/simpler/v2'; 14 14 15 protected $namespace = 'wc/simpler/v2';16 15 /** 17 16 * Route name. … … 27 26 */ 28 27 protected $method = 'POST'; 29 /** 30 * @var UserService 31 */ 28 29 /** @var UserService */ 32 30 private $userService; 33 /** 34 * @var OrderService 35 */ 31 /** @var OrderService */ 36 32 private $orderService; 37 33 … … 39 35 { 40 36 parent::__construct(); 41 $this->userService = $userService ?: newUserService();37 $this->userService = $userService ?: new UserService(); 42 38 $this->orderService = $orderService ?: new OrderService(); 43 39 } … … 54 50 return new WP_REST_Response(json_encode($validation), 422); 55 51 } 56 57 52 $order_request = new OrderRequest( 58 53 User::from_json($body['user']), … … 82 77 83 78 $response = [ 84 'user_id' => strval($user_id),79 'user_id' => strval($user_id), 85 80 'order_id' => strval(apply_filters('simplerwc_order_id', $order->get_id(), $order)) 86 81 ]; -
simpler-checkout/trunk/includes/Http/Controllers/QuotationController.php
r3272319 r3318023 13 13 { 14 14 protected $namespace = 'wc/simpler/v2'; 15 15 16 /** 16 17 * Route name. … … 26 27 */ 27 28 protected $method = 'POST'; 28 /** 29 * @var QuotationService 30 */ 29 30 /** @var QuotationService */ 31 31 protected $quotationService; 32 /** 33 * @var WP_REST_Request 34 */ 32 /** @var WP_REST_Request */ 35 33 private $request; 36 34 … … 47 45 { 48 46 $this->request = $request; 49 $validation = \rest_validate_value_from_schema($this->request->get_json_params(), QuotationSchema::SCHEMA);47 $validation = \rest_validate_value_from_schema($this->request->get_json_params(), QuotationSchema::SCHEMA); 50 48 if (\is_wp_error($validation)) { 51 49 return new WP_REST_Response(json_encode($validation), 422); … … 57 55 return new WP_REST_Response( 58 56 [ 59 'code' => $e instanceof BaseException ? $e->get_error_code() : $e->getCode(),57 'code' => $e instanceof BaseException ? $e->get_error_code() : $e->getCode(), 60 58 'message' => 'Failed to quote cart', 61 'error' => $e->getMessage(),59 'error' => $e->getMessage(), 62 60 ], 63 61 400 64 62 ); 65 63 } 66 67 64 return new WP_REST_Response((new QuotationResponse($quotations))->to_array()); 68 65 } … … 77 74 { 78 75 $items = []; 79 $body = $this->request->get_json_params();76 $body = $this->request->get_json_params(); 80 77 foreach ($body['items'] as $item) { 81 78 $items[] = CartItem::from_json($item); … … 83 80 84 81 $request = new QuotationRequest($items); 85 $request->set_coupon_code($body['coupon'] ?? '') 82 $request 83 ->set_currency($body['currency'] ?? '') 84 ->set_coupon_code($body['coupon'] ?? '') 86 85 ->set_user_email($body['email'] ?? '') 87 86 ->set_shipping_address(isset($body['shipto']) ? Address::from_quotation_json($body['shipto']) : null); -
simpler-checkout/trunk/includes/Http/Payloads/QuotationResponse.php
r3272319 r3318023 9 9 { 10 10 private $response = []; 11 /** 12 * @var Quotation[] 13 */ 11 /** @var Quotation[] */ 14 12 private $quotations; 15 13 … … 25 23 foreach ($this->quotations as $quotation) { 26 24 $response = [ 27 'products' => $this->get_products_response($quotation), 28 'shipping' => $quotation->get_shipping_rate() ? $this->get_shipping_rate_response($quotation) 25 'products' => $this->get_products_response($quotation), 26 'shipping' => $quotation->get_shipping_rate() 27 ? $this->get_shipping_rate_response($quotation) 29 28 : null, 30 29 'discount_cents' => $quotation->get_discount_cents(), 31 'total_cents' => $quotation->get_total_cents(),32 'fees' => $this->get_fees_response($quotation),30 'total_cents' => $quotation->get_total_cents(), 31 'fees' => $this->get_fees_response($quotation), 33 32 ]; 34 33 35 if ($paymentMethods = $this->get_payment_methods_response($quotation)){ 34 if ($currency = $quotation->get_currency()) { 35 $response['currency'] = $currency; 36 } 37 38 if ($paymentMethods = $this->get_payment_methods_response($quotation)) { 36 39 $response['payment_methods'] = $paymentMethods; 37 40 } 38 39 if ($addons = $this->get_addons_response($quotation)) {41 42 if ($addons = $this->get_addons_response($quotation)) { 40 43 $response['addons'] = $addons; 41 44 } … … 55 58 { 56 59 return [ 57 'id' => $quotation->get_shipping_rate()->get_id(),58 'method_id' => $quotation->get_shipping_rate()->get_method_id(),59 'label' => wc_clean($quotation->get_shipping_rate()->get_label()),60 'cost_cents' => $quotation->get_shipping_cents(),61 'tax_cents' => $quotation->get_shipping_tax_cents(),60 'id' => $quotation->get_shipping_rate()->get_id(), 61 'method_id' => $quotation->get_shipping_rate()->get_method_id(), 62 'label' => wc_clean($quotation->get_shipping_rate()->get_label()), 63 'cost_cents' => $quotation->get_shipping_cents(), 64 'tax_cents' => $quotation->get_shipping_tax_cents(), 62 65 'instance_id' => $quotation->get_shipping_rate()->get_instance_id(), 63 66 ]; … … 77 80 foreach ($quotation->get_products() as $product) { 78 81 $data = [ 79 'id' => (string)$product->get_product_id(),80 'quantity' => $product->get_quantity(),82 'id' => (string) $product->get_product_id(), 83 'quantity' => $product->get_quantity(), 81 84 'subtotal_net_cents' => Money::to_cents($product->get_subtotal_net_cost()), 82 85 'subtotal_tax_cents' => Money::to_cents($product->get_subtotal_tax_cost()), 83 'subtotal_cents' => Money::to_cents($product->get_subtotal_cost()),84 'cost_net_cents' => Money::to_cents($product->get_total_net_cost()),85 'cost_tax_cents' => Money::to_cents($product->get_total_tax_cost()),86 'cost_cents' => Money::to_cents($product->get_total_cost()),86 'subtotal_cents' => Money::to_cents($product->get_subtotal_cost()), 87 'cost_net_cents' => Money::to_cents($product->get_total_net_cost()), 88 'cost_tax_cents' => Money::to_cents($product->get_total_tax_cost()), 89 'cost_cents' => Money::to_cents($product->get_total_cost()), 87 90 ]; 88 91 89 if ( !empty($product->get_attributes())) {92 if (!empty($product->get_attributes())) { 90 93 foreach ($product->get_attributes() as $attribute) { 91 94 $data['attributes'][] = ['key' => $attribute->get_key(), 'value' => $attribute->get_value()]; … … 112 115 foreach ($quotation->get_fees() as $fee) { 113 116 $response[] = [ 114 'id' => $fee->get_id(),115 'title' => $fee->get_name(),117 'id' => $fee->get_id(), 118 'title' => $fee->get_name(), 116 119 'cost_cents' => Money::to_cents($fee->get_total() + $fee->get_tax()), 117 120 ]; … … 132 135 foreach ($quotation->get_payment_methods() as $paymentMethod) { 133 136 $paymentMethods[] = [ 134 "id"=> $paymentMethod->getId(),135 "type"=> $paymentMethod->getType(),136 "name"=> $paymentMethod->getName(),137 "net_cents"=> $paymentMethod->getNetCents(),138 "tax_cents"=> $paymentMethod->getTaxCents(),139 "total_cents"=> $paymentMethod->getTotalCents(),137 'id' => $paymentMethod->getId(), 138 'type' => $paymentMethod->getType(), 139 'name' => $paymentMethod->getName(), 140 'net_cents' => $paymentMethod->getNetCents(), 141 'tax_cents' => $paymentMethod->getTaxCents(), 142 'total_cents' => $paymentMethod->getTotalCents(), 140 143 ]; 141 144 } -
simpler-checkout/trunk/includes/Models/OrderRequest.php
r2972503 r3318023 5 5 final class OrderRequest 6 6 { 7 /** 8 * @var User 9 */ 7 /** @var User */ 10 8 private $user; 11 /** 12 * @var Order 13 */ 9 /** @var Order */ 14 10 private $order; 15 /** 16 * @var Address 17 */ 11 /** @var Address */ 18 12 private $shipTo; 19 /** 20 * @var InvoiceDetails | null 21 */ 13 /** @var InvoiceDetails | null */ 22 14 private $invoiceDetails; 23 15 24 16 public function __construct(User $user, Order $order, Address $shipTo = null, InvoiceDetails $invoiceDetails = null) 25 17 { 26 $this->user = $user;27 $this->order = $order;18 $this->user = $user; 19 $this->order = $order; 28 20 $this->shipTo = $shipTo; 29 21 $this->invoiceDetails = $invoiceDetails; -
simpler-checkout/trunk/includes/Models/Quotation.php
r3272319 r3318023 7 7 class Quotation 8 8 { 9 /** 10 * @var int11 */9 /** @var string */ 10 private $currency = ''; 11 /** @var int */ 12 12 private $discountCents = 0; 13 /** 14 * @var WC_Shipping_Rate 15 */ 13 /** @var WC_Shipping_Rate */ 16 14 private $shippingRate; 17 /** 18 * @var int 19 */ 15 /** @var int */ 20 16 private $shippingCents = 0; 21 /** 22 * @var int 23 */ 17 /** @var int */ 24 18 private $shippingTaxCents = 0; 25 /** 26 * @var int 27 */ 19 /** @var int */ 28 20 private $totalCents = 0; 29 /** 30 * @var QuotedProduct[] 31 */ 21 /** @var QuotedProduct[] */ 32 22 private $products = []; 33 /** 34 * @var Fee[] 35 */ 23 /** @var Fee[] */ 36 24 private $fees = []; 37 /** 38 * @var PaymentMethod[] 39 */ 25 /** @var PaymentMethod[] */ 40 26 private $paymentMethods = []; 41 /** 42 * @var array 43 */ 27 /** @var array */ 44 28 private $addons = []; 45 29 46 30 /** 31 * @param string $currency 32 * 33 * @return Quotation 34 */ 35 public function set_currency(string $currency): Quotation 36 { 37 $this->currency = $currency; 38 39 return $this; 40 } 41 42 /** 43 * @return string 44 */ 45 public function get_currency(): string 46 { 47 return $this->currency; 48 } 49 50 /** 47 51 * @param int $discountCents 48 52 * … … 154 158 155 159 return $this; 160 } 161 162 /** 163 * @return Fee[] 164 */ 165 public function get_fees(): array 166 { 167 return $this->fees; 168 } 169 170 /** 171 * @return PaymentMethod[] 172 */ 173 public function get_payment_methods(): array 174 { 175 return $this->paymentMethods; 176 } 177 178 /** 179 * @param PaymentMethod[] $paymentMethods 180 */ 181 public function set_payment_methods(array $paymentMethods) 182 { 183 $this->paymentMethods = $paymentMethods; 184 } 185 186 /** 187 * @return array 188 */ 189 public function get_addons(): array 190 { 191 return $this->addons; 192 } 193 194 /** 195 * @param array 196 */ 197 public function set_addons(array $addons) 198 { 199 $this->addons = $addons; 200 } 156 201 } 157 158 /**159 * @return Fee[]160 */161 public function get_fees(): array162 {163 return $this->fees;164 }165 166 /**167 * @return PaymentMethod[]168 */169 public function get_payment_methods(): array170 {171 return $this->paymentMethods;172 }173 174 /**175 * @param PaymentMethod[] $paymentMethods176 */177 public function set_payment_methods(array $paymentMethods)178 {179 $this->paymentMethods = $paymentMethods;180 }181 182 /**183 * @return array184 */185 public function get_addons(): array186 {187 return $this->addons;188 }189 190 /**191 * @param array192 */193 public function set_addons(array $addons)194 {195 $this->addons = $addons;196 }197 } -
simpler-checkout/trunk/includes/Models/QuotationRequest.php
r2825689 r3318023 5 5 class QuotationRequest 6 6 { 7 /** 8 * @var string9 */7 /** @var string */ 8 private $currency = ''; 9 /** @var string */ 10 10 private $couponCode = ''; 11 /** 12 * @var string 13 */ 11 /** @var string */ 14 12 private $userEmail = ''; 15 /** 16 * @var CartItem[] 17 */ 13 /** @var CartItem[] */ 18 14 private $items; 19 /** 20 * @var Address 21 */ 15 /** @var Address */ 22 16 private $shippingAddress; 23 24 17 25 18 public function __construct(array $items) 26 19 { 27 20 $this->items = $items; 21 } 22 23 /** 24 * @param string $currency 25 * 26 * @return QuotationRequest 27 */ 28 public function set_currency(string $currency = '') 29 { 30 $this->currency = $currency; 31 32 return $this; 28 33 } 29 34 … … 81 86 * @return string 82 87 */ 88 public function get_currency(): string 89 { 90 return $this->currency; 91 } 92 93 /** 94 * @return string 95 */ 83 96 public function get_coupon_code(): string 84 97 { -
simpler-checkout/trunk/includes/Services/CartHelper.php
r3290493 r3318023 48 48 do_action('simplerwc_after_add_to_cart', $productAdded, $item); 49 49 } 50 51 /** 52 * @param string $currency 53 * 54 * @return void 55 */ 56 function switch_currency($currency) 57 { 58 do_action('simplerwc_switch_currency', $currency); 59 60 } 50 61 } -
simpler-checkout/trunk/includes/Services/OrderService.php
r3292379 r3318023 12 12 private $addFeeActionClosure; 13 13 private $addFeeTaxesActionClosure; 14 private $addProductToCartException; 14 15 15 16 /** … … 28 29 wp_set_current_user($user_id); 29 30 $this->initialize_cart(); 31 32 $currency = $order_request->get_order()->get_currency(); 33 $this->switch_currency($currency); 34 30 35 WC()->customer = new \WC_Customer($user_id); 31 36 $order = new \WC_Order(0); … … 37 42 $order_request->get_order()->get_simpler_cart_id() 38 43 ); 44 45 $order->set_currency($currency); 46 $order->update_meta_data('_order_currency', $currency); 47 39 48 $paymentMethodId = $this->get_payment_method_id($order_request); 40 49 WC()->session->set('chosen_payment_method', $paymentMethodId); … … 83 92 $order->set_payment_method_title(SIMPLERWC_PAYMENT_METHOD_SLUG); 84 93 } 94 95 do_action('woocommerce_checkout_create_order', $order, []); 96 $order_id = $order->save(); 97 98 do_action('woocommerce_checkout_update_order_meta', $order_id, []); 99 85 100 $orderStatus = \apply_filters('woocommerce_default_order_status', 'wc-processing'); 86 101 if ($this->get_payment_method_type($order_request) == 'BANK_TRANSFER') { 87 102 $orderStatus = 'on-hold'; 88 103 } 104 $orderStatus = apply_filters('woocommerce_payment_complete_order_status', $orderStatus, $order_id, $order); 89 105 $order->set_status($orderStatus); 90 91 do_action('woocommerce_checkout_create_order', $order, []); 92 $order_id = $order->save(); 93 do_action('woocommerce_checkout_update_order_meta', $order_id, []); 106 $order->save(); 107 94 108 do_action('woocommerce_checkout_order_created', $order); 95 109 do_action('simplerwc_order_created', $order, $order_request); 110 96 111 if ($paymentMethodId == SIMPLERWC_PAYMENT_METHOD_SLUG) { 97 do_action('woocommerce_payment_complete', $order_id );112 do_action('woocommerce_payment_complete', $order_id, null); 98 113 } 99 114 -
simpler-checkout/trunk/includes/Services/QuotationService.php
r3272319 r3318023 3 3 namespace Simpler\Services; 4 4 5 use Exception;6 5 use Simpler\Exceptions\{ 7 6 BaseException, … … 16 15 }; 17 16 use Simpler\Models\{Fee, Money, ProductAttribute, Quotation, QuotationRequest, QuotedProduct}; 17 use Exception; 18 18 19 19 class QuotationService 20 20 { 21 22 21 use CartHelper; 23 22 … … 26 25 */ 27 26 private $request; 27 28 28 /** 29 29 * Add product to cart exception … … 42 42 43 43 /** 44 *45 44 * @return Quotation[] 46 45 * @throws Exception … … 49 48 { 50 49 $this->init(); 51 $quotations = [];50 $quotations = []; 52 51 $this->request = $request; 52 53 if ($currency = $request->get_currency()) { 54 $this->switch_currency($currency); 55 } 53 56 54 57 if ($request->get_user_email()) { … … 57 60 wp_set_current_user($user->ID); 58 61 } else { 59 wp_set_current_user(0); // override rest api access token holder62 wp_set_current_user(0); // override rest api access token holder 60 63 } 61 64 } … … 70 73 if (WC()->cart->needs_shipping() && $this->request->get_shipping_address() !== null) { 71 74 foreach ($this->calculate_shipping_rates() as $shippingRate) { 72 $quotations[] = (new Quotation())->set_ shipping_rate($shippingRate);75 $quotations[] = (new Quotation())->set_currency($currency)->set_shipping_rate($shippingRate); 73 76 } 74 77 } 75 78 76 79 if (empty($quotations)) { 77 $quotations[] = (new Quotation()) ;80 $quotations[] = (new Quotation())->set_currency($currency); 78 81 } 79 82 … … 130 133 131 134 if (!is_null($rate)) { 132 $shippingCost += (float) $rate->get_cost();135 $shippingCost += (float) $rate->get_cost(); 133 136 $shippingTax += array_sum($rate->get_taxes()); 134 137 WC()->session->set('chosen_shipping_methods', [$rate->get_id()]); … … 192 195 $products = []; 193 196 foreach (WC()->cart->get_cart() as $lineItem) { 194 195 197 $lineItem = apply_filters('simplerwc_before_create_quoted_product', $lineItem); 196 198 -
simpler-checkout/trunk/includes/compat.php
r3290493 r3318023 1 1 <?php 2 2 3 include_once('Compatibility/bundles.php'); 4 include_once('Compatibility/cod.php'); 5 include_once('Compatibility/free-gifts.php'); 6 include_once('Compatibility/gift-cards.php'); 7 include_once('Compatibility/gift-wrap.php'); 8 include_once('Compatibility/pickup.php'); 3 include_once ('Compatibility/bundles.php'); 4 include_once ('Compatibility/cod.php'); 5 include_once ('Compatibility/free-gifts.php'); 6 include_once ('Compatibility/gift-cards.php'); 7 include_once ('Compatibility/gift-wrap.php'); 8 include_once ('Compatibility/multi-currency.php'); 9 include_once ('Compatibility/pickup.php'); -
simpler-checkout/trunk/includes/constants.php
r3292379 r3318023 1 1 <?php 2 2 3 const SIMPLERWC_VERSION = '1.1. 8';3 const SIMPLERWC_VERSION = '1.1.9'; 4 4 5 5 function simplerwc_get_sdk_uri() -
simpler-checkout/trunk/simpler.php
r3292379 r3318023 8 8 * Description: Simpler Checkout lets your customers complete their purchases in seconds, with any payment method they want, in any device or browser and without a password. 9 9 * Tags: woocommerce, checkout, payments, conversion rate 10 * Version: 1.1. 810 * Version: 1.1.9 11 11 * Requires at least: 5.1 12 12 * Tested up to: 6.8.1 -
simpler-checkout/trunk/vendor/autoload.php
r3292379 r3318023 5 5 require_once __DIR__ . '/composer/autoload_real.php'; 6 6 7 return ComposerAutoloaderInit 918f6919603832b876aace4236b51c82::getLoader();7 return ComposerAutoloaderInit239c971429cdfb6300f1f3f0c6866574::getLoader(); -
simpler-checkout/trunk/vendor/composer/autoload_real.php
r3292379 r3318023 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit 918f6919603832b876aace4236b51c825 class ComposerAutoloaderInit239c971429cdfb6300f1f3f0c6866574 6 6 { 7 7 private static $loader; … … 25 25 require __DIR__ . '/platform_check.php'; 26 26 27 spl_autoload_register(array('ComposerAutoloaderInit 918f6919603832b876aace4236b51c82', 'loadClassLoader'), true, true);27 spl_autoload_register(array('ComposerAutoloaderInit239c971429cdfb6300f1f3f0c6866574', 'loadClassLoader'), true, true); 28 28 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); 29 spl_autoload_unregister(array('ComposerAutoloaderInit 918f6919603832b876aace4236b51c82', 'loadClassLoader'));29 spl_autoload_unregister(array('ComposerAutoloaderInit239c971429cdfb6300f1f3f0c6866574', 'loadClassLoader')); 30 30 31 31 $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); … … 33 33 require __DIR__ . '/autoload_static.php'; 34 34 35 call_user_func(\Composer\Autoload\ComposerStaticInit 918f6919603832b876aace4236b51c82::getInitializer($loader));35 call_user_func(\Composer\Autoload\ComposerStaticInit239c971429cdfb6300f1f3f0c6866574::getInitializer($loader)); 36 36 } else { 37 37 $map = require __DIR__ . '/autoload_namespaces.php'; -
simpler-checkout/trunk/vendor/composer/autoload_static.php
r3292379 r3318023 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit 918f6919603832b876aace4236b51c827 class ComposerStaticInit239c971429cdfb6300f1f3f0c6866574 8 8 { 9 9 public static $prefixLengthsPsr4 = array ( … … 89 89 { 90 90 return \Closure::bind(function () use ($loader) { 91 $loader->prefixLengthsPsr4 = ComposerStaticInit 918f6919603832b876aace4236b51c82::$prefixLengthsPsr4;92 $loader->prefixDirsPsr4 = ComposerStaticInit 918f6919603832b876aace4236b51c82::$prefixDirsPsr4;93 $loader->classMap = ComposerStaticInit 918f6919603832b876aace4236b51c82::$classMap;91 $loader->prefixLengthsPsr4 = ComposerStaticInit239c971429cdfb6300f1f3f0c6866574::$prefixLengthsPsr4; 92 $loader->prefixDirsPsr4 = ComposerStaticInit239c971429cdfb6300f1f3f0c6866574::$prefixDirsPsr4; 93 $loader->classMap = ComposerStaticInit239c971429cdfb6300f1f3f0c6866574::$classMap; 94 94 95 95 }, null, ClassLoader::class); -
simpler-checkout/trunk/vendor/composer/installed.php
r3292379 r3318023 1 1 <?php return array( 2 2 'root' => array( 3 'pretty_version' => '1.1. 8',4 'version' => '1.1. 8.0',3 'pretty_version' => '1.1.9', 4 'version' => '1.1.9.0', 5 5 'type' => 'wordpress-plugin', 6 6 'install_path' => __DIR__ . '/../../', 7 7 'aliases' => array(), 8 'reference' => ' c25f02a05876bbe56ae9fa3cb4d382a65c3d2159',8 'reference' => 'f3944f97bc78b3ec02b0d2dbb944ade07ddcfe7b', 9 9 'name' => 'simpler-checkout/woo', 10 10 'dev' => false, … … 12 12 'versions' => array( 13 13 'simpler-checkout/woo' => array( 14 'pretty_version' => '1.1. 8',15 'version' => '1.1. 8.0',14 'pretty_version' => '1.1.9', 15 'version' => '1.1.9.0', 16 16 'type' => 'wordpress-plugin', 17 17 'install_path' => __DIR__ . '/../../', 18 18 'aliases' => array(), 19 'reference' => ' c25f02a05876bbe56ae9fa3cb4d382a65c3d2159',19 'reference' => 'f3944f97bc78b3ec02b0d2dbb944ade07ddcfe7b', 20 20 'dev_requirement' => false, 21 21 ),
Note: See TracChangeset
for help on using the changeset viewer.