Plugin Directory

Changeset 3020868


Ignore:
Timestamp:
01/12/2024 09:21:16 AM (2 years ago)
Author:
iwdagency
Message:

Release v1.2.0 with Additional Checkout Fields

Location:
iwd-checkout-connector/trunk
Files:
9 added
12 edited

Legend:

Unmodified
Added
Removed
  • iwd-checkout-connector/trunk/admin/check-connection/iwd-connector-check-connection.php

    r2629644 r3020868  
    6767                case 'wrong_api_credentials':
    6868                    return __( 'Wrong Integration API Credentials' );
    69                 case 'not_configured_payments':
    70                     return __( 'Not Configured Payments' );
    7169                case 'wrong_website_url':
    7270                    return __( 'Wrong Integration Website URL' );
     
    9896                case 'wrong_api_credentials':
    9997                    return __( 'We were unable to locate an Integration with your Api Key & Secret. Please enter valid API Key & Secret from your ' . $checkoutAdminUrl . ' on our ' . $iwdSiteUrl . '.' );
    100                 case 'not_configured_payments':
    101                     return __( 'Your Payment Methods are not configured. Please go to your ' . $checkoutAdminUrl . ' on our ' . $checkoutAdminUrl . ' and configure at least one Payment Method.' );
    10298                case 'wrong_website_url':
    10399                    return __( 'Your current Store URL differs from the Website URL saved for your Integration. Please go to your ' . $checkoutAdminUrl . ' on our ' . $iwdSiteUrl . ' and change Website URL value for your Integration' );
     
    136132        return array(
    137133            'error'   => false,
    138             'massage' => __( 'Connection Successful' ),
     134            'massage' => __( 'Checkout is Successfully Connected!' ),
    139135        );
    140136    }
  • iwd-checkout-connector/trunk/admin/class-iwd-connector-backend.php

    r2946120 r3020868  
    11<?php
     2require_once IWD_CONNECTOR_PATH . 'admin/additional_fields.php';
    23
    34if ( ! class_exists( 'Iwd_Connector_Admin' ) ) {
     
    2829         */
    2930        public function __construct() {
     31            new Iwd_Additional_Fields();
     32           
    3033            add_action( 'admin_menu', array( $this, 'add_admin_menu' ) );
    3134            add_action( 'admin_init', array( $this, 'options_update' ) );
  • iwd-checkout-connector/trunk/admin/templates/settings-options.php

    r2946120 r3020868  
    6161                    <button type="submit" name="Connection Test" id="iwd-connector-connection-test">Connection Test<br>
    6262                    </button>
     63                    <p>Check to make sure your payment methods are configured within Dominate's Checkout Admin Panel to continue using</p>
    6364                </td>
    6465            </tr>
  • iwd-checkout-connector/trunk/includes/api/class-iwd-con-api.php

    r2540679 r3020868  
    5151    }
    5252
    53     /**
    54      * Save data to session
    55      *
    56      * @param $quote_id
    57      */
     53    /**
     54     * Save data to session
     55     *
     56     * @param $quote_id
     57     * @throws Exception
     58     */
    5859    public function setSessionData( $quote_id ) {
    5960        $session_data = $this->getSessionData( $quote_id );
     
    6566        WC()->session->set( 'coupon_discount_tax_totals', maybe_unserialize( $session_data['coupon_discount_tax_totals'] ) );
    6667        WC()->session->set( 'removed_cart_contents', maybe_unserialize( $session_data['removed_cart_contents'] ) );
    67         WC()->session->set( 'customer', $customer );
    68         WC()->customer->set_id( $customer['id'] );
     68
     69        $this->setCustomerAddress($customer);
    6970
    7071        if ( ! empty( $session_data['cart_fees'] ) ) {
    7172            WC()->session->set( 'cart_fees', maybe_unserialize( $session_data['cart_fees'] ) );
    7273        }
     74
     75        WC()->customer->set_calculated_shipping( true );
     76        WC()->customer->save();
     77
    7378        WC()->session->save_data();
    7479        WC()->cart->set_session();
     
    109114    }
    110115
     116    /**
     117     * @return void
     118     * @throws Exception
     119     *
     120     */
     121    private function setCustomerAddress($customer) {
     122        WC()->customer = new WC_Customer( $customer['id'], true );
     123
     124        WC()->customer->set_shipping_first_name( $customer['shipping_first_name']  );
     125        WC()->customer->set_shipping_last_name( $customer['shipping_last_name']  );
     126        WC()->customer->set_shipping_address( $customer['shipping_address_1']  );
     127        WC()->customer->set_shipping_country( $customer['shipping_country']  );
     128        WC()->customer->set_shipping_state( $customer['shipping_state']  );
     129        WC()->customer->set_shipping_city( $customer['shipping_city']  );
     130        WC()->customer->set_shipping_postcode( $customer['shipping_postcode'] );
     131        WC()->customer->set_shipping_phone( $customer['shipping_phone']);
     132
     133        WC()->customer->set_billing_first_name($customer['first_name']);
     134        WC()->customer->set_billing_last_name($customer['last_name']);
     135        WC()->customer->set_billing_address($customer['address']);
     136        WC()->customer->set_billing_country($customer['country']);
     137        WC()->customer->set_billing_state( $customer['state']  );
     138        WC()->customer->set_billing_city( $customer['city'] );
     139        WC()->customer->set_billing_postcode( $customer['postcode'] );
     140        WC()->customer->set_billing_phone( $customer['phone']);
     141        WC()->customer->set_billing_email( $customer['email']  );
     142    }
    111143}
  • iwd-checkout-connector/trunk/includes/api/class-iwd-con-place-order.php

    r2946120 r3020868  
    129129            $order->set_shipping_city($this->customer_data['shipping_city']);
    130130            $order->set_shipping_postcode($this->customer_data['shipping_postcode']);
     131            $order->set_shipping_phone($this->customer_data['shipping_phone']);
    131132
    132133            // apply coupons
     
    146147            $order->set_prices_include_tax('yes' === get_option('woocommerce_prices_include_tax'));
    147148
    148             if ($api->data->comments) {
    149                 foreach ($api->data->comments as $comments) {
    150                     $order->add_order_note(__($comments));
    151                 }
    152             }
    153 
    154             // set payment method
    155             $methodCode = $this->parseMethodCode($api->data->payment_method_code);
    156             $methodTitle = $api->data->payment_method_title;
    157             $paymentAction = $api->data->payment_action;
    158             $offlinePayments = [
    159                 'zero', 'purchaseorder', 'custom', 'check_or_money_order', 'cash_on_delivery', 'banktransfer',
    160                 'multiple_offline',
    161             ];
    162 
    163             $order->add_meta_data(self::TRANSACTION_STATUS, $paymentAction, true);
    164             $order->set_payment_method_title($methodTitle);
    165             $order->calculate_totals();
     149            // set payment method
     150            $methodCode = $this->parseMethodCode($api->data->payment_method_code);
     151            $methodTitle = $api->data->payment_method_title;
     152            $paymentAction = $api->data->payment_action;
     153            $offlinePayments = [
     154                'zero', 'purchaseorder', 'custom', 'check_or_money_order', 'cash_on_delivery', 'banktransfer',
     155                'multiple_offline',
     156            ];
     157
     158            $order->add_meta_data( self::TRANSACTION_STATUS, $paymentAction, true );
     159            $order->set_payment_method_title($methodTitle);
     160            $order->calculate_totals();
     161            $this->addAdditionalFields($api->data->custom_data->dominate, $order->get_id() );
     162
     163            if ($api->data->comments) {
     164                foreach ($api->data->comments as $comments) {
     165                    $order->add_order_note(sprintf(__($comments)));
     166                }
     167            }
     168
     169            $order->save();
     170
     171            $calculate_tax_args = array(
     172                'country'  => $this->customer_data['shipping_country'],
     173                'state'    => $this->customer_data['shipping_state'],
     174                'postcode' =>  $this->customer_data['postcode'],
     175                'city'     => $this->customer_data['city'],
     176            );
     177
     178            // Save order items first.
     179            if (function_exists('wc_save_order_items'))
     180                wc_save_order_items( $order->get_id(), $order->get_items() );
     181
     182            // Grab the order and recalculate taxes.
     183            $order = wc_get_order( $order->get_id() );
     184            $order->calculate_taxes( $calculate_tax_args );
     185            $order->calculate_totals( false );
    166186
    167187            if (in_array($methodCode, $offlinePayments)) {
     
    219239    }
    220240
    221     /**
    222      * @param $data
    223      *
    224      * @return void
    225      * @throws Exception
    226      */
     241    /**
     242     * @param $data
     243     * @param $orderId
     244     * @return void
     245     */
     246    private function addAdditionalFields($data, $orderId)
     247    {
     248        if($data->additional){
     249            foreach ($data->additional as $placement => $data)
     250            {
     251                update_post_meta($orderId, $placement, json_encode($data) );
     252            }
     253        }
     254    }
     255
     256    /**
     257     * @param $data
     258     * @param $customer_data
     259     * @return void
     260     */
    227261    private function processDominateData($data)
    228262    {
     
    232266            } elseif ($key === 'create_customer_account' && !$this->customer_data['id']) {
    233267                $customer = new Iwd_Connector_Customer();
    234    
     268
    235269                $customer->setData($this->customer_data);
    236270                $customer->assignCustomerToOrder();
    237    
     271
    238272                $this->customer_data['id'] = $customer->getId();
    239273            }
  • iwd-checkout-connector/trunk/includes/model/cart/class-iwd-con-cart.php

    r2946120 r3020868  
    1616
    1717        return [
     18            'version' => esc_html(IWD_CONNECTOR_VERSION) ?? null,
    1819            'is_virtual' =>$this->getIsVirtual($session_data),
    1920            'currency' => get_woocommerce_currency(),
  • iwd-checkout-connector/trunk/includes/model/customer/class-iwd-con-customer.php

    r2946120 r3020868  
    100100        WC()->customer = new WC_Customer( $customer_id, true );
    101101        WC()->customer->set_billing_email( $addresses->email );
    102         WC()->customer->set_address_2( $addresses->ship_bill_to_different_address );
    103102
    104103        $this->setBilling( $addresses->billing );
  • iwd-checkout-connector/trunk/includes/model/session/class-iwd-con-cart-session.php

    r2540679 r3020868  
    2121            )
    2222        );
     23
     24        $this->destroy_session();
    2325    }
    2426
  • iwd-checkout-connector/trunk/iwd-checkout-connector.php

    r2971737 r3020868  
    55 * Description: Checkout Suite Connector
    66 * Author: Dominate
    7  * Version: 1.1.2
     7 * Version: 1.2.0
    88 * Author URI: https://www.dominate.co/
    99 * WC requires at least: 2.6.0
    10  * WC tested up to: 7.8.0
     10 * WC tested up to: 8.4.0
    1111 */
    1212
     
    3030             * Define plugin minimums and constants.
    3131             */
    32             define( 'IWD_CONNECTOR_VERSION', '1.1.2' );
     32            define( 'IWD_CONNECTOR_VERSION', '1.2.0' );
    3333            define( 'IWD_CONNECTOR_FILE', __FILE__ );
    3434            define( 'IWD_CONNECTOR_PATH', plugin_dir_path( __FILE__ ) );
  • iwd-checkout-connector/trunk/public/class-iwd-connector-frontend.php

    r2862744 r3020868  
    5454         * @return string
    5555         */
    56         public function modify_thank_you_details( $thank_you_title, $order ){
     56        public function modify_thank_you_details( $thank_you_title ){
     57            global $wp;
     58
    5759            $html = '<p>'.$thank_you_title.'</p>';
     60            $order = wc_get_order($wp->query_vars['order-received']);
    5861
    59             if ($order->get_payment_method_title() === 'PayPal - Pay Upon Invoice') {
     62            if ($order && $order->get_payment_method_title() === 'PayPal - Pay Upon Invoice') {
    6063                $html .= '<p><b>'.__('Important', 'woocommerce').'</b>: ';
    6164                $html .= __('Please review the payment instructions that have been sent to your email.', 'woocommerce').'</p>';
  • iwd-checkout-connector/trunk/public/templates/iwd-checkout-saas.php

    r2971737 r3020868  
    1 <input type="email" name="billing_email" id="billing_email" style="display: none">
     1<form class="woocommerce-checkout" style="display: none">
     2    <input type="email" name="billing_email" id="billing_email" style="display: none">
     3</form>
    24
    35<iframe id="iwdCheckoutFrame"
  • iwd-checkout-connector/trunk/readme.txt

    r2946120 r3020868  
    1 === Dominate Checkout Suite (Saas) ===
     1=== Dominate Checkout (SaaS) ===
    22Author URI: https://www.dominate.co/
    33Plugin URI: https://www.dominate.co/woocommerce
     
    66Requires at least: 5.0
    77Requires PHP: 7.0
    8 Tested up to: 6.2.2
     8Tested up to: 6.4.2
    99Stable tag: 2.0.14
    1010WC requires at least: 3.6.0
    11 WC tested up to: 7.8.0
     11WC tested up to: 8.4.0
    1212License: GPLv3
    1313License URI: http://www.gnu.org/licenses/gpl-3.0.html
Note: See TracChangeset for help on using the changeset viewer.