Plugin Directory

Changeset 3318023


Ignore:
Timestamp:
06/26/2025 07:02:35 AM (9 months ago)
Author:
simplercheckout
Message:

Version 1.1.9

Location:
simpler-checkout
Files:
2 added
36 edited
1 copied

Legend:

Unmodified
Added
Removed
  • simpler-checkout/tags/1.1.9/README.txt

    r3292379 r3318023  
    55Tested up to: 6.5
    66Requires PHP: 7.0
    7 Stable tag: 1.1.8
     7Stable tag: 1.1.9
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    3535
    3636== Changelog ==
     37
     38== 1.1.9
     39Compat: [WPML Multicurrency](https://wordpress.org/plugins/woocommerce-multilingual/)
     40Compat: [Pre-Orders for WooCommerce](https://wordpress.org/plugins/pre-orders-for-woocommerce/)
    3741
    3842== 1.1.8
  • simpler-checkout/tags/1.1.9/includes/Compatibility/cod.php

    r3290493 r3318023  
    55use Simpler\Models\PaymentMethod;
    66use Simpler\Models\Quotation;
     7
     8function 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}
    726
    827/**
     
    2039    }
    2140
    22     if (!defined('DOING_AJAX'))
    23         define('DOING_AJAX', true);
    2441    $availablePaymentMethods = WC()->payment_gateways->get_available_payment_gateways();
    2542
     
    2744    if (isset($availablePaymentMethods['cod'])) {
    2845        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) {
    3249                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                 }
    4050            }
    4151        } else if (class_exists('Pay4Pay')) {
     
    7888
    7989    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        // };
    86106    }
    87107    return $closures;
  • simpler-checkout/tags/1.1.9/includes/Http/Controllers/OrderController.php

    r3041307 r3318023  
    99use WP_REST_Response;
    1010
    11 
    1211class OrderController extends Controller
    1312{
     13    protected $namespace = 'wc/simpler/v2';
    1414
    15     protected $namespace = 'wc/simpler/v2';
    1615    /**
    1716     * Route name.
     
    2726     */
    2827    protected $method = 'POST';
    29     /**
    30      * @var UserService
    31      */
     28
     29    /** @var UserService */
    3230    private $userService;
    33     /**
    34      * @var OrderService
    35      */
     31    /** @var OrderService */
    3632    private $orderService;
    3733
     
    3935    {
    4036        parent::__construct();
    41         $this->userService  = $userService ?: new UserService();
     37        $this->userService = $userService ?: new UserService();
    4238        $this->orderService = $orderService ?: new OrderService();
    4339    }
     
    5450            return new WP_REST_Response(json_encode($validation), 422);
    5551        }
    56 
    5752        $order_request = new OrderRequest(
    5853            User::from_json($body['user']),
     
    8277
    8378        $response = [
    84             'user_id'  => strval($user_id),
     79            'user_id' => strval($user_id),
    8580            'order_id' => strval(apply_filters('simplerwc_order_id', $order->get_id(), $order))
    8681        ];
  • simpler-checkout/tags/1.1.9/includes/Http/Controllers/QuotationController.php

    r3272319 r3318023  
    1313{
    1414    protected $namespace = 'wc/simpler/v2';
     15
    1516    /**
    1617     * Route name.
     
    2627     */
    2728    protected $method = 'POST';
    28     /**
    29      * @var QuotationService
    30      */
     29
     30    /** @var QuotationService */
    3131    protected $quotationService;
    32     /**
    33      * @var WP_REST_Request
    34      */
     32    /** @var WP_REST_Request */
    3533    private $request;
    3634
     
    4745    {
    4846        $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);
    5048        if (\is_wp_error($validation)) {
    5149            return new WP_REST_Response(json_encode($validation), 422);
     
    5755            return new WP_REST_Response(
    5856                [
    59                     'code'    => $e instanceof BaseException ? $e->get_error_code() : $e->getCode(),
     57                    'code' => $e instanceof BaseException ? $e->get_error_code() : $e->getCode(),
    6058                    'message' => 'Failed to quote cart',
    61                     'error'   => $e->getMessage(),
     59                    'error' => $e->getMessage(),
    6260                ],
    6361                400
    6462            );
    6563        }
    66 
    6764        return new WP_REST_Response((new QuotationResponse($quotations))->to_array());
    6865    }
     
    7774    {
    7875        $items = [];
    79         $body  = $this->request->get_json_params();
     76        $body = $this->request->get_json_params();
    8077        foreach ($body['items'] as $item) {
    8178            $items[] = CartItem::from_json($item);
     
    8380
    8481        $request = new QuotationRequest($items);
    85         $request->set_coupon_code($body['coupon'] ?? '')
     82        $request
     83            ->set_currency($body['currency'] ?? '')
     84            ->set_coupon_code($body['coupon'] ?? '')
    8685            ->set_user_email($body['email'] ?? '')
    8786            ->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  
    99{
    1010    private $response = [];
    11     /**
    12      * @var Quotation[]
    13      */
     11    /** @var Quotation[] */
    1412    private $quotations;
    1513
     
    2523        foreach ($this->quotations as $quotation) {
    2624            $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)
    2928                    : null,
    3029                '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),
    3332            ];
    3433
    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)) {
    3639                $response['payment_methods'] = $paymentMethods;
    3740            }
    38            
    39             if ($addons = $this->get_addons_response($quotation)){
     41
     42            if ($addons = $this->get_addons_response($quotation)) {
    4043                $response['addons'] = $addons;
    4144            }
     
    5558    {
    5659        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(),
    6265            'instance_id' => $quotation->get_shipping_rate()->get_instance_id(),
    6366        ];
     
    7780        foreach ($quotation->get_products() as $product) {
    7881            $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(),
    8184                'subtotal_net_cents' => Money::to_cents($product->get_subtotal_net_cost()),
    8285                '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()),
    8790            ];
    8891
    89             if ( ! empty($product->get_attributes())) {
     92            if (!empty($product->get_attributes())) {
    9093                foreach ($product->get_attributes() as $attribute) {
    9194                    $data['attributes'][] = ['key' => $attribute->get_key(), 'value' => $attribute->get_value()];
     
    112115        foreach ($quotation->get_fees() as $fee) {
    113116            $response[] = [
    114                 'id'         => $fee->get_id(),
    115                 'title'      => $fee->get_name(),
     117                'id' => $fee->get_id(),
     118                'title' => $fee->get_name(),
    116119                'cost_cents' => Money::to_cents($fee->get_total() + $fee->get_tax()),
    117120            ];
     
    132135        foreach ($quotation->get_payment_methods() as $paymentMethod) {
    133136            $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(),
    140143            ];
    141144        }
  • simpler-checkout/tags/1.1.9/includes/Models/OrderRequest.php

    r2972503 r3318023  
    55final class OrderRequest
    66{
    7     /**
    8      * @var User
    9      */
     7    /** @var User */
    108    private $user;
    11     /**
    12      * @var Order
    13      */
     9    /** @var Order */
    1410    private $order;
    15     /**
    16      * @var Address
    17      */
     11    /** @var Address */
    1812    private $shipTo;
    19     /**
    20      * @var InvoiceDetails | null
    21      */
     13    /** @var InvoiceDetails | null */
    2214    private $invoiceDetails;
    2315
    2416    public function __construct(User $user, Order $order, Address $shipTo = null, InvoiceDetails $invoiceDetails = null)
    2517    {
    26         $this->user   = $user;
    27         $this->order  = $order;
     18        $this->user = $user;
     19        $this->order = $order;
    2820        $this->shipTo = $shipTo;
    2921        $this->invoiceDetails = $invoiceDetails;
  • simpler-checkout/tags/1.1.9/includes/Models/Quotation.php

    r3272319 r3318023  
    77class Quotation
    88{
    9     /**
    10      * @var int
    11     */
     9    /** @var string */
     10    private $currency = '';
     11    /** @var int */
    1212    private $discountCents = 0;
    13     /**
    14      * @var WC_Shipping_Rate
    15      */
     13    /** @var WC_Shipping_Rate */
    1614    private $shippingRate;
    17     /**
    18      * @var int
    19      */
     15    /** @var int */
    2016    private $shippingCents = 0;
    21     /**
    22      * @var int
    23      */
     17    /** @var int */
    2418    private $shippingTaxCents = 0;
    25     /**
    26      * @var int
    27      */
     19    /** @var int */
    2820    private $totalCents = 0;
    29     /**
    30      * @var QuotedProduct[]
    31      */
     21    /** @var QuotedProduct[] */
    3222    private $products = [];
    33     /**
    34      * @var Fee[]
    35      */
     23    /** @var Fee[] */
    3624    private $fees = [];
    37     /**
    38      * @var PaymentMethod[]
    39      */
     25    /** @var PaymentMethod[] */
    4026    private $paymentMethods = [];
    41     /**
    42      * @var array
    43      */
     27    /** @var array */
    4428    private $addons = [];
    4529
    4630    /**
     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    /**
    4751     * @param  int  $discountCents
    4852     *
     
    154158
    155159        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    }
    156201}
    157 
    158     /**
    159      * @return Fee[]
    160      */
    161     public function get_fees(): array
    162     {
    163         return $this->fees;
    164     }
    165 
    166     /**
    167      * @return PaymentMethod[]
    168      */
    169     public function get_payment_methods(): array
    170     {
    171         return $this->paymentMethods;
    172     }
    173 
    174     /**
    175      * @param  PaymentMethod[]  $paymentMethods
    176      */
    177     public function set_payment_methods(array $paymentMethods)
    178     {
    179         $this->paymentMethods = $paymentMethods;
    180     }
    181 
    182     /**
    183      * @return array
    184      */
    185     public function get_addons(): array
    186     {
    187         return $this->addons;
    188     }
    189 
    190     /**
    191      * @param array
    192      */
    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  
    55class QuotationRequest
    66{
    7     /**
    8      * @var string
    9     */
     7    /** @var string */
     8    private $currency = '';
     9    /** @var string */
    1010    private $couponCode = '';
    11     /**
    12      * @var string
    13      */
     11    /** @var string */
    1412    private $userEmail = '';
    15     /**
    16      * @var CartItem[]
    17      */
     13    /** @var CartItem[] */
    1814    private $items;
    19     /**
    20      * @var Address
    21      */
     15    /** @var Address */
    2216    private $shippingAddress;
    23 
    2417
    2518    public function __construct(array $items)
    2619    {
    2720        $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;
    2833    }
    2934
     
    8186     * @return string
    8287     */
     88    public function get_currency(): string
     89    {
     90        return $this->currency;
     91    }
     92
     93    /**
     94     * @return string
     95     */
    8396    public function get_coupon_code(): string
    8497    {
  • simpler-checkout/tags/1.1.9/includes/Services/CartHelper.php

    r3290493 r3318023  
    4848        do_action('simplerwc_after_add_to_cart', $productAdded, $item);
    4949    }
     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    }
    5061}
  • simpler-checkout/tags/1.1.9/includes/Services/OrderService.php

    r3292379 r3318023  
    1212    private $addFeeActionClosure;
    1313    private $addFeeTaxesActionClosure;
     14    private $addProductToCartException;
    1415
    1516    /**
     
    2829        wp_set_current_user($user_id);
    2930        $this->initialize_cart();
     31
     32        $currency = $order_request->get_order()->get_currency();
     33        $this->switch_currency($currency);
     34
    3035        WC()->customer = new \WC_Customer($user_id);
    3136        $order = new \WC_Order(0);
     
    3742            $order_request->get_order()->get_simpler_cart_id()
    3843        );
     44
     45        $order->set_currency($currency);
     46        $order->update_meta_data('_order_currency', $currency);
     47       
    3948        $paymentMethodId = $this->get_payment_method_id($order_request);
    4049        WC()->session->set('chosen_payment_method', $paymentMethodId);
     
    8392            $order->set_payment_method_title(SIMPLERWC_PAYMENT_METHOD_SLUG);
    8493        }
     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
    85100        $orderStatus = \apply_filters('woocommerce_default_order_status', 'wc-processing');
    86101        if ($this->get_payment_method_type($order_request) == 'BANK_TRANSFER') {
    87102            $orderStatus = 'on-hold';
    88103        }
     104        $orderStatus = apply_filters('woocommerce_payment_complete_order_status', $orderStatus, $order_id, $order);
    89105        $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
    94108        do_action('woocommerce_checkout_order_created', $order);
    95109        do_action('simplerwc_order_created', $order, $order_request);
     110
    96111        if ($paymentMethodId == SIMPLERWC_PAYMENT_METHOD_SLUG) {
    97             do_action('woocommerce_payment_complete', $order_id);
     112            do_action('woocommerce_payment_complete', $order_id, null);
    98113        }
    99114
  • simpler-checkout/tags/1.1.9/includes/Services/QuotationService.php

    r3272319 r3318023  
    33namespace Simpler\Services;
    44
    5 use Exception;
    65use Simpler\Exceptions\{
    76    BaseException,
     
    1615};
    1716use Simpler\Models\{Fee, Money, ProductAttribute, Quotation, QuotationRequest, QuotedProduct};
     17use Exception;
    1818
    1919class QuotationService
    2020{
    21 
    2221    use CartHelper;
    2322
     
    2625     */
    2726    private $request;
     27
    2828    /**
    2929     * Add product to cart exception
     
    4242
    4343    /**
    44      *
    4544     * @return Quotation[]
    4645     * @throws Exception
     
    4948    {
    5049        $this->init();
    51         $quotations    = [];
     50        $quotations = [];
    5251        $this->request = $request;
     52
     53        if ($currency = $request->get_currency()) {
     54            $this->switch_currency($currency);
     55        }
    5356
    5457        if ($request->get_user_email()) {
     
    5760                wp_set_current_user($user->ID);
    5861            } else {
    59                 wp_set_current_user(0); // override rest api access token holder
     62                wp_set_current_user(0);  // override rest api access token holder
    6063            }
    6164        }
     
    7073        if (WC()->cart->needs_shipping() && $this->request->get_shipping_address() !== null) {
    7174            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);
    7376            }
    7477        }
    7578
    7679        if (empty($quotations)) {
    77             $quotations[] = (new Quotation());
     80            $quotations[] = (new Quotation())->set_currency($currency);
    7881        }
    7982
     
    130133
    131134            if (!is_null($rate)) {
    132                 $shippingCost += (float)$rate->get_cost();
     135                $shippingCost += (float) $rate->get_cost();
    133136                $shippingTax += array_sum($rate->get_taxes());
    134137                WC()->session->set('chosen_shipping_methods', [$rate->get_id()]);
     
    192195        $products = [];
    193196        foreach (WC()->cart->get_cart() as $lineItem) {
    194 
    195197            $lineItem = apply_filters('simplerwc_before_create_quoted_product', $lineItem);
    196198
  • simpler-checkout/tags/1.1.9/includes/compat.php

    r3290493 r3318023  
    11<?php
    22
    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');
     3include_once ('Compatibility/bundles.php');
     4include_once ('Compatibility/cod.php');
     5include_once ('Compatibility/free-gifts.php');
     6include_once ('Compatibility/gift-cards.php');
     7include_once ('Compatibility/gift-wrap.php');
     8include_once ('Compatibility/multi-currency.php');
     9include_once ('Compatibility/pickup.php');
  • simpler-checkout/tags/1.1.9/includes/constants.php

    r3292379 r3318023  
    11<?php
    22
    3 const SIMPLERWC_VERSION = '1.1.8';
     3const SIMPLERWC_VERSION = '1.1.9';
    44
    55function simplerwc_get_sdk_uri()
  • simpler-checkout/tags/1.1.9/simpler.php

    r3292379 r3318023  
    88 * 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.
    99 * Tags: woocommerce, checkout, payments, conversion rate
    10  * Version: 1.1.8
     10 * Version: 1.1.9
    1111 * Requires at least: 5.1
    1212 * Tested up to: 6.8.1
  • simpler-checkout/tags/1.1.9/vendor/autoload.php

    r3292379 r3318023  
    55require_once __DIR__ . '/composer/autoload_real.php';
    66
    7 return ComposerAutoloaderInit918f6919603832b876aace4236b51c82::getLoader();
     7return ComposerAutoloaderInit239c971429cdfb6300f1f3f0c6866574::getLoader();
  • simpler-checkout/tags/1.1.9/vendor/composer/autoload_real.php

    r3292379 r3318023  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit918f6919603832b876aace4236b51c82
     5class ComposerAutoloaderInit239c971429cdfb6300f1f3f0c6866574
    66{
    77    private static $loader;
     
    2525        require __DIR__ . '/platform_check.php';
    2626
    27         spl_autoload_register(array('ComposerAutoloaderInit918f6919603832b876aace4236b51c82', 'loadClassLoader'), true, true);
     27        spl_autoload_register(array('ComposerAutoloaderInit239c971429cdfb6300f1f3f0c6866574', 'loadClassLoader'), true, true);
    2828        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
    29         spl_autoload_unregister(array('ComposerAutoloaderInit918f6919603832b876aace4236b51c82', 'loadClassLoader'));
     29        spl_autoload_unregister(array('ComposerAutoloaderInit239c971429cdfb6300f1f3f0c6866574', 'loadClassLoader'));
    3030
    3131        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
     
    3333            require __DIR__ . '/autoload_static.php';
    3434
    35             call_user_func(\Composer\Autoload\ComposerStaticInit918f6919603832b876aace4236b51c82::getInitializer($loader));
     35            call_user_func(\Composer\Autoload\ComposerStaticInit239c971429cdfb6300f1f3f0c6866574::getInitializer($loader));
    3636        } else {
    3737            $map = require __DIR__ . '/autoload_namespaces.php';
  • simpler-checkout/tags/1.1.9/vendor/composer/autoload_static.php

    r3292379 r3318023  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInit918f6919603832b876aace4236b51c82
     7class ComposerStaticInit239c971429cdfb6300f1f3f0c6866574
    88{
    99    public static $prefixLengthsPsr4 = array (
     
    8989    {
    9090        return \Closure::bind(function () use ($loader) {
    91             $loader->prefixLengthsPsr4 = ComposerStaticInit918f6919603832b876aace4236b51c82::$prefixLengthsPsr4;
    92             $loader->prefixDirsPsr4 = ComposerStaticInit918f6919603832b876aace4236b51c82::$prefixDirsPsr4;
    93             $loader->classMap = ComposerStaticInit918f6919603832b876aace4236b51c82::$classMap;
     91            $loader->prefixLengthsPsr4 = ComposerStaticInit239c971429cdfb6300f1f3f0c6866574::$prefixLengthsPsr4;
     92            $loader->prefixDirsPsr4 = ComposerStaticInit239c971429cdfb6300f1f3f0c6866574::$prefixDirsPsr4;
     93            $loader->classMap = ComposerStaticInit239c971429cdfb6300f1f3f0c6866574::$classMap;
    9494
    9595        }, null, ClassLoader::class);
  • simpler-checkout/tags/1.1.9/vendor/composer/installed.php

    r3292379 r3318023  
    11<?php return array(
    22    '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',
    55        'type' => 'wordpress-plugin',
    66        'install_path' => __DIR__ . '/../../',
    77        'aliases' => array(),
    8         'reference' => 'c25f02a05876bbe56ae9fa3cb4d382a65c3d2159',
     8        'reference' => 'f3944f97bc78b3ec02b0d2dbb944ade07ddcfe7b',
    99        'name' => 'simpler-checkout/woo',
    1010        'dev' => false,
     
    1212    'versions' => array(
    1313        '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',
    1616            'type' => 'wordpress-plugin',
    1717            'install_path' => __DIR__ . '/../../',
    1818            'aliases' => array(),
    19             'reference' => 'c25f02a05876bbe56ae9fa3cb4d382a65c3d2159',
     19            'reference' => 'f3944f97bc78b3ec02b0d2dbb944ade07ddcfe7b',
    2020            'dev_requirement' => false,
    2121        ),
  • simpler-checkout/trunk/README.txt

    r3292379 r3318023  
    55Tested up to: 6.5
    66Requires PHP: 7.0
    7 Stable tag: 1.1.8
     7Stable tag: 1.1.9
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    3535
    3636== Changelog ==
     37
     38== 1.1.9
     39Compat: [WPML Multicurrency](https://wordpress.org/plugins/woocommerce-multilingual/)
     40Compat: [Pre-Orders for WooCommerce](https://wordpress.org/plugins/pre-orders-for-woocommerce/)
    3741
    3842== 1.1.8
  • simpler-checkout/trunk/includes/Compatibility/cod.php

    r3290493 r3318023  
    55use Simpler\Models\PaymentMethod;
    66use Simpler\Models\Quotation;
     7
     8function 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}
    726
    827/**
     
    2039    }
    2140
    22     if (!defined('DOING_AJAX'))
    23         define('DOING_AJAX', true);
    2441    $availablePaymentMethods = WC()->payment_gateways->get_available_payment_gateways();
    2542
     
    2744    if (isset($availablePaymentMethods['cod'])) {
    2845        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) {
    3249                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                 }
    4050            }
    4151        } else if (class_exists('Pay4Pay')) {
     
    7888
    7989    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        // };
    86106    }
    87107    return $closures;
  • simpler-checkout/trunk/includes/Http/Controllers/OrderController.php

    r3041307 r3318023  
    99use WP_REST_Response;
    1010
    11 
    1211class OrderController extends Controller
    1312{
     13    protected $namespace = 'wc/simpler/v2';
    1414
    15     protected $namespace = 'wc/simpler/v2';
    1615    /**
    1716     * Route name.
     
    2726     */
    2827    protected $method = 'POST';
    29     /**
    30      * @var UserService
    31      */
     28
     29    /** @var UserService */
    3230    private $userService;
    33     /**
    34      * @var OrderService
    35      */
     31    /** @var OrderService */
    3632    private $orderService;
    3733
     
    3935    {
    4036        parent::__construct();
    41         $this->userService  = $userService ?: new UserService();
     37        $this->userService = $userService ?: new UserService();
    4238        $this->orderService = $orderService ?: new OrderService();
    4339    }
     
    5450            return new WP_REST_Response(json_encode($validation), 422);
    5551        }
    56 
    5752        $order_request = new OrderRequest(
    5853            User::from_json($body['user']),
     
    8277
    8378        $response = [
    84             'user_id'  => strval($user_id),
     79            'user_id' => strval($user_id),
    8580            'order_id' => strval(apply_filters('simplerwc_order_id', $order->get_id(), $order))
    8681        ];
  • simpler-checkout/trunk/includes/Http/Controllers/QuotationController.php

    r3272319 r3318023  
    1313{
    1414    protected $namespace = 'wc/simpler/v2';
     15
    1516    /**
    1617     * Route name.
     
    2627     */
    2728    protected $method = 'POST';
    28     /**
    29      * @var QuotationService
    30      */
     29
     30    /** @var QuotationService */
    3131    protected $quotationService;
    32     /**
    33      * @var WP_REST_Request
    34      */
     32    /** @var WP_REST_Request */
    3533    private $request;
    3634
     
    4745    {
    4846        $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);
    5048        if (\is_wp_error($validation)) {
    5149            return new WP_REST_Response(json_encode($validation), 422);
     
    5755            return new WP_REST_Response(
    5856                [
    59                     'code'    => $e instanceof BaseException ? $e->get_error_code() : $e->getCode(),
     57                    'code' => $e instanceof BaseException ? $e->get_error_code() : $e->getCode(),
    6058                    'message' => 'Failed to quote cart',
    61                     'error'   => $e->getMessage(),
     59                    'error' => $e->getMessage(),
    6260                ],
    6361                400
    6462            );
    6563        }
    66 
    6764        return new WP_REST_Response((new QuotationResponse($quotations))->to_array());
    6865    }
     
    7774    {
    7875        $items = [];
    79         $body  = $this->request->get_json_params();
     76        $body = $this->request->get_json_params();
    8077        foreach ($body['items'] as $item) {
    8178            $items[] = CartItem::from_json($item);
     
    8380
    8481        $request = new QuotationRequest($items);
    85         $request->set_coupon_code($body['coupon'] ?? '')
     82        $request
     83            ->set_currency($body['currency'] ?? '')
     84            ->set_coupon_code($body['coupon'] ?? '')
    8685            ->set_user_email($body['email'] ?? '')
    8786            ->set_shipping_address(isset($body['shipto']) ? Address::from_quotation_json($body['shipto']) : null);
  • simpler-checkout/trunk/includes/Http/Payloads/QuotationResponse.php

    r3272319 r3318023  
    99{
    1010    private $response = [];
    11     /**
    12      * @var Quotation[]
    13      */
     11    /** @var Quotation[] */
    1412    private $quotations;
    1513
     
    2523        foreach ($this->quotations as $quotation) {
    2624            $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)
    2928                    : null,
    3029                '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),
    3332            ];
    3433
    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)) {
    3639                $response['payment_methods'] = $paymentMethods;
    3740            }
    38            
    39             if ($addons = $this->get_addons_response($quotation)){
     41
     42            if ($addons = $this->get_addons_response($quotation)) {
    4043                $response['addons'] = $addons;
    4144            }
     
    5558    {
    5659        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(),
    6265            'instance_id' => $quotation->get_shipping_rate()->get_instance_id(),
    6366        ];
     
    7780        foreach ($quotation->get_products() as $product) {
    7881            $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(),
    8184                'subtotal_net_cents' => Money::to_cents($product->get_subtotal_net_cost()),
    8285                '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()),
    8790            ];
    8891
    89             if ( ! empty($product->get_attributes())) {
     92            if (!empty($product->get_attributes())) {
    9093                foreach ($product->get_attributes() as $attribute) {
    9194                    $data['attributes'][] = ['key' => $attribute->get_key(), 'value' => $attribute->get_value()];
     
    112115        foreach ($quotation->get_fees() as $fee) {
    113116            $response[] = [
    114                 'id'         => $fee->get_id(),
    115                 'title'      => $fee->get_name(),
     117                'id' => $fee->get_id(),
     118                'title' => $fee->get_name(),
    116119                'cost_cents' => Money::to_cents($fee->get_total() + $fee->get_tax()),
    117120            ];
     
    132135        foreach ($quotation->get_payment_methods() as $paymentMethod) {
    133136            $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(),
    140143            ];
    141144        }
  • simpler-checkout/trunk/includes/Models/OrderRequest.php

    r2972503 r3318023  
    55final class OrderRequest
    66{
    7     /**
    8      * @var User
    9      */
     7    /** @var User */
    108    private $user;
    11     /**
    12      * @var Order
    13      */
     9    /** @var Order */
    1410    private $order;
    15     /**
    16      * @var Address
    17      */
     11    /** @var Address */
    1812    private $shipTo;
    19     /**
    20      * @var InvoiceDetails | null
    21      */
     13    /** @var InvoiceDetails | null */
    2214    private $invoiceDetails;
    2315
    2416    public function __construct(User $user, Order $order, Address $shipTo = null, InvoiceDetails $invoiceDetails = null)
    2517    {
    26         $this->user   = $user;
    27         $this->order  = $order;
     18        $this->user = $user;
     19        $this->order = $order;
    2820        $this->shipTo = $shipTo;
    2921        $this->invoiceDetails = $invoiceDetails;
  • simpler-checkout/trunk/includes/Models/Quotation.php

    r3272319 r3318023  
    77class Quotation
    88{
    9     /**
    10      * @var int
    11     */
     9    /** @var string */
     10    private $currency = '';
     11    /** @var int */
    1212    private $discountCents = 0;
    13     /**
    14      * @var WC_Shipping_Rate
    15      */
     13    /** @var WC_Shipping_Rate */
    1614    private $shippingRate;
    17     /**
    18      * @var int
    19      */
     15    /** @var int */
    2016    private $shippingCents = 0;
    21     /**
    22      * @var int
    23      */
     17    /** @var int */
    2418    private $shippingTaxCents = 0;
    25     /**
    26      * @var int
    27      */
     19    /** @var int */
    2820    private $totalCents = 0;
    29     /**
    30      * @var QuotedProduct[]
    31      */
     21    /** @var QuotedProduct[] */
    3222    private $products = [];
    33     /**
    34      * @var Fee[]
    35      */
     23    /** @var Fee[] */
    3624    private $fees = [];
    37     /**
    38      * @var PaymentMethod[]
    39      */
     25    /** @var PaymentMethod[] */
    4026    private $paymentMethods = [];
    41     /**
    42      * @var array
    43      */
     27    /** @var array */
    4428    private $addons = [];
    4529
    4630    /**
     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    /**
    4751     * @param  int  $discountCents
    4852     *
     
    154158
    155159        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    }
    156201}
    157 
    158     /**
    159      * @return Fee[]
    160      */
    161     public function get_fees(): array
    162     {
    163         return $this->fees;
    164     }
    165 
    166     /**
    167      * @return PaymentMethod[]
    168      */
    169     public function get_payment_methods(): array
    170     {
    171         return $this->paymentMethods;
    172     }
    173 
    174     /**
    175      * @param  PaymentMethod[]  $paymentMethods
    176      */
    177     public function set_payment_methods(array $paymentMethods)
    178     {
    179         $this->paymentMethods = $paymentMethods;
    180     }
    181 
    182     /**
    183      * @return array
    184      */
    185     public function get_addons(): array
    186     {
    187         return $this->addons;
    188     }
    189 
    190     /**
    191      * @param array
    192      */
    193     public function set_addons(array $addons)
    194     {
    195         $this->addons = $addons;
    196     }
    197 }
  • simpler-checkout/trunk/includes/Models/QuotationRequest.php

    r2825689 r3318023  
    55class QuotationRequest
    66{
    7     /**
    8      * @var string
    9     */
     7    /** @var string */
     8    private $currency = '';
     9    /** @var string */
    1010    private $couponCode = '';
    11     /**
    12      * @var string
    13      */
     11    /** @var string */
    1412    private $userEmail = '';
    15     /**
    16      * @var CartItem[]
    17      */
     13    /** @var CartItem[] */
    1814    private $items;
    19     /**
    20      * @var Address
    21      */
     15    /** @var Address */
    2216    private $shippingAddress;
    23 
    2417
    2518    public function __construct(array $items)
    2619    {
    2720        $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;
    2833    }
    2934
     
    8186     * @return string
    8287     */
     88    public function get_currency(): string
     89    {
     90        return $this->currency;
     91    }
     92
     93    /**
     94     * @return string
     95     */
    8396    public function get_coupon_code(): string
    8497    {
  • simpler-checkout/trunk/includes/Services/CartHelper.php

    r3290493 r3318023  
    4848        do_action('simplerwc_after_add_to_cart', $productAdded, $item);
    4949    }
     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    }
    5061}
  • simpler-checkout/trunk/includes/Services/OrderService.php

    r3292379 r3318023  
    1212    private $addFeeActionClosure;
    1313    private $addFeeTaxesActionClosure;
     14    private $addProductToCartException;
    1415
    1516    /**
     
    2829        wp_set_current_user($user_id);
    2930        $this->initialize_cart();
     31
     32        $currency = $order_request->get_order()->get_currency();
     33        $this->switch_currency($currency);
     34
    3035        WC()->customer = new \WC_Customer($user_id);
    3136        $order = new \WC_Order(0);
     
    3742            $order_request->get_order()->get_simpler_cart_id()
    3843        );
     44
     45        $order->set_currency($currency);
     46        $order->update_meta_data('_order_currency', $currency);
     47       
    3948        $paymentMethodId = $this->get_payment_method_id($order_request);
    4049        WC()->session->set('chosen_payment_method', $paymentMethodId);
     
    8392            $order->set_payment_method_title(SIMPLERWC_PAYMENT_METHOD_SLUG);
    8493        }
     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
    85100        $orderStatus = \apply_filters('woocommerce_default_order_status', 'wc-processing');
    86101        if ($this->get_payment_method_type($order_request) == 'BANK_TRANSFER') {
    87102            $orderStatus = 'on-hold';
    88103        }
     104        $orderStatus = apply_filters('woocommerce_payment_complete_order_status', $orderStatus, $order_id, $order);
    89105        $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
    94108        do_action('woocommerce_checkout_order_created', $order);
    95109        do_action('simplerwc_order_created', $order, $order_request);
     110
    96111        if ($paymentMethodId == SIMPLERWC_PAYMENT_METHOD_SLUG) {
    97             do_action('woocommerce_payment_complete', $order_id);
     112            do_action('woocommerce_payment_complete', $order_id, null);
    98113        }
    99114
  • simpler-checkout/trunk/includes/Services/QuotationService.php

    r3272319 r3318023  
    33namespace Simpler\Services;
    44
    5 use Exception;
    65use Simpler\Exceptions\{
    76    BaseException,
     
    1615};
    1716use Simpler\Models\{Fee, Money, ProductAttribute, Quotation, QuotationRequest, QuotedProduct};
     17use Exception;
    1818
    1919class QuotationService
    2020{
    21 
    2221    use CartHelper;
    2322
     
    2625     */
    2726    private $request;
     27
    2828    /**
    2929     * Add product to cart exception
     
    4242
    4343    /**
    44      *
    4544     * @return Quotation[]
    4645     * @throws Exception
     
    4948    {
    5049        $this->init();
    51         $quotations    = [];
     50        $quotations = [];
    5251        $this->request = $request;
     52
     53        if ($currency = $request->get_currency()) {
     54            $this->switch_currency($currency);
     55        }
    5356
    5457        if ($request->get_user_email()) {
     
    5760                wp_set_current_user($user->ID);
    5861            } else {
    59                 wp_set_current_user(0); // override rest api access token holder
     62                wp_set_current_user(0);  // override rest api access token holder
    6063            }
    6164        }
     
    7073        if (WC()->cart->needs_shipping() && $this->request->get_shipping_address() !== null) {
    7174            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);
    7376            }
    7477        }
    7578
    7679        if (empty($quotations)) {
    77             $quotations[] = (new Quotation());
     80            $quotations[] = (new Quotation())->set_currency($currency);
    7881        }
    7982
     
    130133
    131134            if (!is_null($rate)) {
    132                 $shippingCost += (float)$rate->get_cost();
     135                $shippingCost += (float) $rate->get_cost();
    133136                $shippingTax += array_sum($rate->get_taxes());
    134137                WC()->session->set('chosen_shipping_methods', [$rate->get_id()]);
     
    192195        $products = [];
    193196        foreach (WC()->cart->get_cart() as $lineItem) {
    194 
    195197            $lineItem = apply_filters('simplerwc_before_create_quoted_product', $lineItem);
    196198
  • simpler-checkout/trunk/includes/compat.php

    r3290493 r3318023  
    11<?php
    22
    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');
     3include_once ('Compatibility/bundles.php');
     4include_once ('Compatibility/cod.php');
     5include_once ('Compatibility/free-gifts.php');
     6include_once ('Compatibility/gift-cards.php');
     7include_once ('Compatibility/gift-wrap.php');
     8include_once ('Compatibility/multi-currency.php');
     9include_once ('Compatibility/pickup.php');
  • simpler-checkout/trunk/includes/constants.php

    r3292379 r3318023  
    11<?php
    22
    3 const SIMPLERWC_VERSION = '1.1.8';
     3const SIMPLERWC_VERSION = '1.1.9';
    44
    55function simplerwc_get_sdk_uri()
  • simpler-checkout/trunk/simpler.php

    r3292379 r3318023  
    88 * 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.
    99 * Tags: woocommerce, checkout, payments, conversion rate
    10  * Version: 1.1.8
     10 * Version: 1.1.9
    1111 * Requires at least: 5.1
    1212 * Tested up to: 6.8.1
  • simpler-checkout/trunk/vendor/autoload.php

    r3292379 r3318023  
    55require_once __DIR__ . '/composer/autoload_real.php';
    66
    7 return ComposerAutoloaderInit918f6919603832b876aace4236b51c82::getLoader();
     7return ComposerAutoloaderInit239c971429cdfb6300f1f3f0c6866574::getLoader();
  • simpler-checkout/trunk/vendor/composer/autoload_real.php

    r3292379 r3318023  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit918f6919603832b876aace4236b51c82
     5class ComposerAutoloaderInit239c971429cdfb6300f1f3f0c6866574
    66{
    77    private static $loader;
     
    2525        require __DIR__ . '/platform_check.php';
    2626
    27         spl_autoload_register(array('ComposerAutoloaderInit918f6919603832b876aace4236b51c82', 'loadClassLoader'), true, true);
     27        spl_autoload_register(array('ComposerAutoloaderInit239c971429cdfb6300f1f3f0c6866574', 'loadClassLoader'), true, true);
    2828        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
    29         spl_autoload_unregister(array('ComposerAutoloaderInit918f6919603832b876aace4236b51c82', 'loadClassLoader'));
     29        spl_autoload_unregister(array('ComposerAutoloaderInit239c971429cdfb6300f1f3f0c6866574', 'loadClassLoader'));
    3030
    3131        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
     
    3333            require __DIR__ . '/autoload_static.php';
    3434
    35             call_user_func(\Composer\Autoload\ComposerStaticInit918f6919603832b876aace4236b51c82::getInitializer($loader));
     35            call_user_func(\Composer\Autoload\ComposerStaticInit239c971429cdfb6300f1f3f0c6866574::getInitializer($loader));
    3636        } else {
    3737            $map = require __DIR__ . '/autoload_namespaces.php';
  • simpler-checkout/trunk/vendor/composer/autoload_static.php

    r3292379 r3318023  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInit918f6919603832b876aace4236b51c82
     7class ComposerStaticInit239c971429cdfb6300f1f3f0c6866574
    88{
    99    public static $prefixLengthsPsr4 = array (
     
    8989    {
    9090        return \Closure::bind(function () use ($loader) {
    91             $loader->prefixLengthsPsr4 = ComposerStaticInit918f6919603832b876aace4236b51c82::$prefixLengthsPsr4;
    92             $loader->prefixDirsPsr4 = ComposerStaticInit918f6919603832b876aace4236b51c82::$prefixDirsPsr4;
    93             $loader->classMap = ComposerStaticInit918f6919603832b876aace4236b51c82::$classMap;
     91            $loader->prefixLengthsPsr4 = ComposerStaticInit239c971429cdfb6300f1f3f0c6866574::$prefixLengthsPsr4;
     92            $loader->prefixDirsPsr4 = ComposerStaticInit239c971429cdfb6300f1f3f0c6866574::$prefixDirsPsr4;
     93            $loader->classMap = ComposerStaticInit239c971429cdfb6300f1f3f0c6866574::$classMap;
    9494
    9595        }, null, ClassLoader::class);
  • simpler-checkout/trunk/vendor/composer/installed.php

    r3292379 r3318023  
    11<?php return array(
    22    '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',
    55        'type' => 'wordpress-plugin',
    66        'install_path' => __DIR__ . '/../../',
    77        'aliases' => array(),
    8         'reference' => 'c25f02a05876bbe56ae9fa3cb4d382a65c3d2159',
     8        'reference' => 'f3944f97bc78b3ec02b0d2dbb944ade07ddcfe7b',
    99        'name' => 'simpler-checkout/woo',
    1010        'dev' => false,
     
    1212    'versions' => array(
    1313        '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',
    1616            'type' => 'wordpress-plugin',
    1717            'install_path' => __DIR__ . '/../../',
    1818            'aliases' => array(),
    19             'reference' => 'c25f02a05876bbe56ae9fa3cb4d382a65c3d2159',
     19            'reference' => 'f3944f97bc78b3ec02b0d2dbb944ade07ddcfe7b',
    2020            'dev_requirement' => false,
    2121        ),
Note: See TracChangeset for help on using the changeset viewer.