Plugin Directory

Changeset 2852878


Ignore:
Timestamp:
01/23/2023 11:54:37 AM (3 years ago)
Author:
sprinque
Message:

v.1.2.3

Location:
sprinque
Files:
16 edited
1 copied

Legend:

Unmodified
Added
Removed
  • sprinque/tags/1.2.3/assets/css/frontend.css

    r2849745 r2852878  
    593593}
    594594.search-company-by input[type=radio] + .input-placeholder {
     595  position: relative;
    595596  display: inline-block;
    596597  width: 18px;
     
    602603  border: 1px solid #B5B9E2;
    603604}
     605.search-company-by input[type=radio] + .input-placeholder:after {
     606  content: "";
     607  position: absolute;
     608  display: none;
     609  top: 3px;
     610  left: 6px;
     611  width: 5px;
     612  height: 9px;
     613  border: solid white;
     614  border-width: 0 2px 2px 0;
     615  -webkit-transform: rotate(45deg);
     616  -ms-transform: rotate(45deg);
     617  transform: rotate(45deg);
     618}
    604619.search-company-by input[type=radio]:checked + .input-placeholder {
    605620  background-color: #00033C;
    606621  border-color: #00033C;
    607   background-image: url("../img/checkmark.png");
    608   background-repeat: no-repeat;
    609   background-position: center center;
     622}
     623.search-company-by input[type=radio]:checked + .input-placeholder:after {
     624  display: block;
    610625}
    611626
  • sprinque/tags/1.2.3/assets/css/frontend.scss

    r2849745 r2852878  
    769769
    770770    & + .input-placeholder {
     771      position: relative;
    771772      display: inline-block;
    772773      width:  18px;
     
    777778      box-sizing: border-box;
    778779      border: 1px solid #B5B9E2;
     780
     781      &:after {
     782        content: "";
     783        position: absolute;
     784        display: none;
     785        top: 3px;
     786        left: 6px;
     787        width: 5px;
     788        height: 9px;
     789        border: solid white;
     790        border-width: 0 2px 2px 0;
     791        -webkit-transform: rotate(45deg);
     792        -ms-transform: rotate(45deg);
     793        transform: rotate(45deg);
     794      }
    779795    }
    780796    &:checked + .input-placeholder {
    781797      background-color: #00033C;
    782798      border-color: #00033C;
    783       background-image: url("../img/checkmark.png");
    784       background-repeat: no-repeat;
    785       background-position: center center;
     799      //background-image: url("../img/checkmark.png");
     800      //background-repeat: no-repeat;
     801      //background-position: center center;
     802      &:after {
     803        display: block;
     804      }
    786805    }
    787806  }
  • sprinque/tags/1.2.3/assets/js/frontend.js

    r2849745 r2852878  
    149149    var orderPayed = false;
    150150
     151    var buyer_email;
     152    var merchant_buyer_id;
     153
    151154    $("body").on("click", "#place_order", function(event) {
    152155        if(!orderPayed && $('#payment_method_wpm_srinque_pay').length && $('#payment_method_wpm_srinque_pay').is(':checked')) {
     
    177180            showPopup('#wpm-modal-form');
    178181
    179             // Exclude Sprinque domains from the fullstory
    180             let hostname = window.location.hostname;
    181             if(hostname !== 'sprinque.wp-masters.com' && hostname !== 'wp-demo.sprinque.com'){
    182                 window['_fs_host'] = 'fullstory.com';
    183                 window['_fs_script'] = 'edge.fullstory.com/s/fs.js';
    184                 window['_fs_org'] = 'o-1ESJKB-na1';
    185                 window['_fs_namespace'] = 'FS';
    186                 (function(m,n,e,t,l,o,g,y){
    187                     if (e in m) {if(m.console && m.console.log) { m.console.log('FullStory namespace conflict. Please set window["_fs_namespace"].');} return;}
    188                     g=m[e]=function(a,b,s){g.q?g.q.push([a,b,s]):g._api(a,b,s);};g.q=[];
    189                     o=n.createElement(t);o.async=1;o.crossOrigin='anonymous';o.src='https://'+_fs_script;
    190                     y=n.getElementsByTagName(t)[0];y.parentNode.insertBefore(o,y);
    191                     g.identify=function(i,v,s){g(l,{uid:i},s);if(v)g(l,v,s)};g.setUserVars=function(v,s){g(l,v,s)};g.event=function(i,v,s){g('event',{n:i,p:v},s)};
    192                     g.anonymize=function(){g.identify(!!0)};
    193                     g.shutdown=function(){g("rec",!1)};g.restart=function(){g("rec",!0)};
    194                     g.log = function(a,b){g("log",[a,b])};
    195                     g.consent=function(a){g("consent",!arguments.length||a)};
    196                     g.identifyAccount=function(i,v){o='account';v=v||{};v.acctId=i;g(o,v)};
    197                     g.clearUserCookie=function(){};
    198                     g.setVars=function(n, p){g('setVars',[n,p]);};
    199                     g._w={};y='XMLHttpRequest';g._w[y]=m[y];y='fetch';g._w[y]=m[y];
    200                     if(m[y])m[y]=function(){return g._w[y].apply(this,arguments)};
    201                     g._v="1.3.0";
    202                 })(window,document,window['_fs_namespace'],'script','user');
    203             }
     182            // Set buyer email
     183            buyer_email = $('#billing_email').val();
     184
     185            // // Exclude Sprinque domains from the fullstory
     186            // let hostname = window.location.hostname;
     187            // if(hostname !== 'sprinque.wp-masters.com' && hostname !== 'wp-demo.sprinque.com'){
     188            //     window['_fs_host'] = 'fullstory.com';
     189            //     window['_fs_script'] = 'edge.fullstory.com/s/fs.js';
     190            //     window['_fs_org'] = 'o-1ESJKB-na1';
     191            //     window['_fs_namespace'] = 'FS';
     192            //     (function(m,n,e,t,l,o,g,y){
     193            //         if (e in m) {if(m.console && m.console.log) { m.console.log('FullStory namespace conflict. Please set window["_fs_namespace"].');} return;}
     194            //         g=m[e]=function(a,b,s){g.q?g.q.push([a,b,s]):g._api(a,b,s);};g.q=[];
     195            //         o=n.createElement(t);o.async=1;o.crossOrigin='anonymous';o.src='https://'+_fs_script;
     196            //         y=n.getElementsByTagName(t)[0];y.parentNode.insertBefore(o,y);
     197            //         g.identify=function(i,v,s){g(l,{uid:i},s);if(v)g(l,v,s)};g.setUserVars=function(v,s){g(l,v,s)};g.event=function(i,v,s){g('event',{n:i,p:v},s)};
     198            //         g.anonymize=function(){g.identify(!!0)};
     199            //         g.shutdown=function(){g("rec",!1)};g.restart=function(){g("rec",!0)};
     200            //         g.log = function(a,b){g("log",[a,b])};
     201            //         g.consent=function(a){g("consent",!arguments.length||a)};
     202            //         g.identifyAccount=function(i,v){o='account';v=v||{};v.acctId=i;g(o,v)};
     203            //         g.clearUserCookie=function(){};
     204            //         g.setVars=function(n, p){g('setVars',[n,p]);};
     205            //         g._w={};y='XMLHttpRequest';g._w[y]=m[y];y='fetch';g._w[y]=m[y];
     206            //         if(m[y])m[y]=function(){return g._w[y].apply(this,arguments)};
     207            //         g._v="1.3.0";
     208            //     })(window,document,window['_fs_namespace'],'script','user');
     209            // }
    204210
    205211        }
     
    271277            if($(this).val() == country) {
    272278                $('#select_country_pay').wpmSelect('setVal', country);
     279                $('#company_name_pay').val($('#billing_company').val());
    273280            }
    274281        });
     
    385392
    386393    });
    387 
    388     var buyer_email;
    389     var merchant_buyer_id;
    390394
    391395    $("body").on("click", "#register_buyer_company", function(event) {
     
    441445                        }
    442446                    } else {
    443                         $('.error-register-fields').html(response.message).show();
     447                        let errorMessages = response.message;
     448                        if ('response' in response && 'errors' in response.response) {
     449                            errorMessages += searchAdditionalErrorHandler(response.response.errors)
     450                        }
     451
     452                        $('.error-confirm-order').html(errorMessages).show();
    444453                    }
    445454                }
     
    568577                        }
    569578                    } else {
    570                         $('.error-confirm-order').show().html(response.message);
     579                        let errorMessages = response.message;
     580                        if ('response' in response && 'errors' in response.response) {
     581                            errorMessages += searchAdditionalErrorHandler(response.response.errors)
     582                        }
     583
     584                        $('.error-confirm-order').show().html(errorMessages);
    571585                    }
    572586                }
     
    576590        }
    577591    });
     592
     593    function searchAdditionalErrorHandler(data) {
     594        let resultHtml = '';
     595
     596        try {
     597            for (let key in data) {
     598                data[key].forEach(errors => {
     599                    for (let field in errors) {
     600                        errors[field].forEach(message => {
     601                            resultHtml += '<p>' + message + '</p>';
     602                        });
     603                    }
     604                });
     605            }
     606        } catch (e) {
     607            console.log(e);
     608        }
     609
     610        return resultHtml;
     611    }
    578612
    579613    function verify_company() {
     
    786820        var search_by = $('input[name="search_by"]:checked').val();
    787821
    788         if(country_code.length > 0 && company_name.length > 1 && !orderPayed) {
     822        if(country_code.length > 0 && company_name.length > 2 && !orderPayed) {
    789823
    790824            $('.search-company-result').addClass('search-company-result_loading');
  • sprinque/tags/1.2.3/include/payment_method.php

    r2849683 r2852878  
    2727add_action( 'wp_ajax_nopriv_sprinque_register_buyer', 'sprinque_register_buyer_api', 99 );
    2828
    29 add_action( 'wp_ajax_sprinque_get_business_details', 'sprinque_get_business_details', 99 );
    30 add_action( 'wp_ajax_nopriv_sprinque_get_business_details', 'sprinque_get_business_details', 99 );
    31 
    3229add_action( 'wp_ajax_sprinque_get_countries_api', 'sprinque_get_countries_api', 99 );
    3330add_action( 'wp_ajax_nopriv_sprinque_get_countries_api', 'sprinque_get_countries_api', 99 );
     
    3936    $SrinquePay = new WPM_SrinquePay;
    4037    $SrinquePay->sprinque_get_buyer_info();
    41 }
    42 
    43 /**
    44  * Get Buyer Info
    45  */
    46 function sprinque_get_business_details() {
    47     $SrinquePay = new WPM_SrinquePay;
    48     $SrinquePay->sprinque_get_business_details();
    4938}
    5039
     
    170159
    171160            include( PLUGIN_SRINQUE_DIR . '/templates/frontend/srinque_pay_modal_form.php' );
    172         }
    173 
    174         /**
    175          * Get List Sprinque companies
    176          */
    177         public function sprinque_get_business_details() {
    178             if (! isset( $_POST['country_code'] ) || ! isset( $_POST['registration_number'] ) ) {
    179                 return false;
    180             }
    181 
    182             $data = [
    183                 'country_code'        => sanitize_text_field($_POST['country_code']),
    184                 'registration_number' => sanitize_text_field($_POST['registration_number'])
    185             ];
    186 
    187             $business = $this->srinque_api( $data, 'POST', '/search/business/details' );
    188 
    189             ob_start();
    190             include( PLUGIN_SRINQUE_DIR . '/templates/ajax/company_item.php' );
    191             $result = ob_get_clean();
    192 
    193             wp_send_json( [
    194                 'status'  => 'true',
    195                 'html'    => $result
    196             ] );
    197161        }
    198162
  • sprinque/tags/1.2.3/languages/sprinque.po

    r2849683 r2852878  
    117117msgstr ""
    118118
    119 msgid "Company name"
    120 msgstr ""
    121 
     119#: templates/frontend/srinque_pay_modal_form.php:31
    122120msgid "VAT ID"
     121msgstr ""
     122
     123#: templates/frontend/srinque_pay_modal_form.php:29
     124msgid "Company VAT ID"
    123125msgstr ""
    124126
     
    180182#: templates/frontend/srinque_pay_modal_form.php:21
    181183#: templates/frontend/srinque_pay_modal_form.php:22
     184#: templates/frontend/srinque_pay_modal_form.php:24
     185#: templates/frontend/srinque_pay_modal_form.php:26
    182186msgid "Company Name"
    183187msgstr ""
  • sprinque/tags/1.2.3/languages/sprinque.pot

    r2849683 r2852878  
    6161msgstr ""
    6262
    63 msgid "Company name"
    64 msgstr ""
    65 
     63#: templates/frontend/srinque_pay_modal_form.php:31
    6664msgid "VAT ID"
     65msgstr ""
     66
     67#: templates/frontend/srinque_pay_modal_form.php:29
     68msgid "Company VAT ID"
    6769msgstr ""
    6870
     
    109111#: templates/frontend/srinque_pay_modal_form.php:21
    110112#: templates/frontend/srinque_pay_modal_form.php:22
     113#: templates/frontend/srinque_pay_modal_form.php:24
     114#: templates/frontend/srinque_pay_modal_form.php:26
    111115msgid "Company Name"
    112116msgstr ""
  • sprinque/tags/1.2.3/readme.txt

    r2849745 r2852878  
    66Tested up to: 6.0
    77Requires PHP: 5.3
    8 Stable tag: 1.2.2
     8Stable tag: 1.2.3
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    5050
    5151== Changelog ==
     52
     53= 1.2.3 - January 20, 2023 =
     54* Fixed save-checkout-fields-issue;
     55* Block search for less than 2 characters;
     56* The API errors have been displayed;
     57* Search to be executed when the country is changed;
     58* Edit email in the root form is reflected in the sprinque otp;
     59* Delete unused legacy search/business/details;
     60* Fixed vat-id related .po and .pot translations;
     61* Improved the search checkbox quality;
     62* Turned off the fullstory;
     63* Used PLUGIN_SRINQUE_VERSION for styles and js;
    5264
    5365= 1.2.2 - January 17, 2023 =
  • sprinque/tags/1.2.3/sprinque.php

    r2849745 r2852878  
    55Description: Sprinque for WordPress is a plugin that allows you to offer your business buyers net payment terms (15, 30, 60, 90 days) and thereby grow conversion and retention.
    66Author: Sprinque
    7 Version: 1.2.2
     7Version: 1.2.3
    88Text Domain: sprinque
    99Domain Path: /languages
    1010*/
    1111
     12define( 'PLUGIN_SRINQUE_VERSION', '1.2.3' );
    1213define( 'PLUGIN_SRINQUE_DIR', __DIR__ );
    1314define( 'PLUGIN_SRINQUE_PATH', plugins_url( '', __FILE__ ) );
     
    6263        // WebHook functions
    6364        add_action( 'init', [ $this, 'get_webhook_response' ], 99 );
    64         add_action( 'init', [ $this, 'save_checkout_fields' ], 99 );
     65        add_action( 'woocommerce_checkout_update_order_review', [ $this, 'save_checkout_fields' ], 99 );
    6566
    6667        // Orders and cart
     
    243244     */
    244245    public function save_checkout_fields() {
    245         if (isset( $_POST['post_data'])) {
    246             // Get Form data from Checkout
    247             $form_data = explode( '&', sanitize_text_field( $_POST['post_data'] ) );
    248             $filtered  = [];
    249 
    250             // Prepare Array
    251             foreach ( $form_data as $value ) {
    252                 $sliced                 = explode( '=', $value );
    253                 $filtered[ $sliced[0] ] = $sliced[1];
    254             }
    255 
    256             // Set Customer Billing Data
    257             $this->setCustomerBillingData($filtered);
    258 
    259             // Set Customer Shipping Data
    260             $this->setCustomerShippingData($filtered);
    261         }
     246        // Get Form data from Checkout
     247        $form_data = explode( '&', sanitize_text_field( $_POST['post_data'] ) );
     248        $filtered  = [];
     249
     250        // Prepare Array
     251        foreach ( $form_data as $value ) {
     252            $sliced                 = explode( '=', $value );
     253            $filtered[ $sliced[0] ] = $sliced[1];
     254        }
     255
     256        // Set Customer Billing Data
     257        $this->setCustomerBillingData($filtered);
     258
     259        // Set Customer Shipping Data
     260        $this->setCustomerShippingData($filtered);
    262261    }
    263262
     
    443442                    // Prepare Data to Send
    444443                    $data = [
    445                         'merchant_order_id' =>  $order_id_from_sequential_plugin ?: $order->get_id(),
     444                        'merchant_order_id' =>  ( $order_id_from_sequential_plugin ?: $order->get_id() ) . '_wh',
    446445                        'order_amount'      => $order->get_total(),
    447446                        'shipping_address'  => [
     
    559558    public function include_scripts_and_styles() {
    560559        // Register styles
    561         wp_enqueue_style( 'wpm_srinque_pay', PLUGIN_SRINQUE_PATH . '/assets/css/frontend.css', false, '1.0.91', 'all' );
     560        wp_enqueue_style( 'wpm_srinque_pay', PLUGIN_SRINQUE_PATH . '/assets/css/frontend.css', false, PLUGIN_SRINQUE_VERSION, 'all' );
    562561
    563562        // Register scripts
    564563        $settings = get_option( 'woocommerce_wpm_srinque_pay_settings', true );
    565         wp_enqueue_script( 'wpm_srinque_pay', PLUGIN_SRINQUE_PATH . '/assets/js/frontend.js', array( 'jquery' ), '1.0.91', 'all' );
     564        wp_enqueue_script( 'wpm_srinque_pay', PLUGIN_SRINQUE_PATH . '/assets/js/frontend.js', array( 'jquery' ), PLUGIN_SRINQUE_VERSION, 'all' );
    566565        wp_localize_script( 'wpm_srinque_pay', 'admin', array(
    567566            'ajaxurl' => admin_url( 'admin-ajax.php' ),
  • sprinque/trunk/assets/css/frontend.css

    r2849745 r2852878  
    593593}
    594594.search-company-by input[type=radio] + .input-placeholder {
     595  position: relative;
    595596  display: inline-block;
    596597  width: 18px;
     
    602603  border: 1px solid #B5B9E2;
    603604}
     605.search-company-by input[type=radio] + .input-placeholder:after {
     606  content: "";
     607  position: absolute;
     608  display: none;
     609  top: 3px;
     610  left: 6px;
     611  width: 5px;
     612  height: 9px;
     613  border: solid white;
     614  border-width: 0 2px 2px 0;
     615  -webkit-transform: rotate(45deg);
     616  -ms-transform: rotate(45deg);
     617  transform: rotate(45deg);
     618}
    604619.search-company-by input[type=radio]:checked + .input-placeholder {
    605620  background-color: #00033C;
    606621  border-color: #00033C;
    607   background-image: url("../img/checkmark.png");
    608   background-repeat: no-repeat;
    609   background-position: center center;
     622}
     623.search-company-by input[type=radio]:checked + .input-placeholder:after {
     624  display: block;
    610625}
    611626
  • sprinque/trunk/assets/css/frontend.scss

    r2849745 r2852878  
    769769
    770770    & + .input-placeholder {
     771      position: relative;
    771772      display: inline-block;
    772773      width:  18px;
     
    777778      box-sizing: border-box;
    778779      border: 1px solid #B5B9E2;
     780
     781      &:after {
     782        content: "";
     783        position: absolute;
     784        display: none;
     785        top: 3px;
     786        left: 6px;
     787        width: 5px;
     788        height: 9px;
     789        border: solid white;
     790        border-width: 0 2px 2px 0;
     791        -webkit-transform: rotate(45deg);
     792        -ms-transform: rotate(45deg);
     793        transform: rotate(45deg);
     794      }
    779795    }
    780796    &:checked + .input-placeholder {
    781797      background-color: #00033C;
    782798      border-color: #00033C;
    783       background-image: url("../img/checkmark.png");
    784       background-repeat: no-repeat;
    785       background-position: center center;
     799      //background-image: url("../img/checkmark.png");
     800      //background-repeat: no-repeat;
     801      //background-position: center center;
     802      &:after {
     803        display: block;
     804      }
    786805    }
    787806  }
  • sprinque/trunk/assets/js/frontend.js

    r2849745 r2852878  
    149149    var orderPayed = false;
    150150
     151    var buyer_email;
     152    var merchant_buyer_id;
     153
    151154    $("body").on("click", "#place_order", function(event) {
    152155        if(!orderPayed && $('#payment_method_wpm_srinque_pay').length && $('#payment_method_wpm_srinque_pay').is(':checked')) {
     
    177180            showPopup('#wpm-modal-form');
    178181
    179             // Exclude Sprinque domains from the fullstory
    180             let hostname = window.location.hostname;
    181             if(hostname !== 'sprinque.wp-masters.com' && hostname !== 'wp-demo.sprinque.com'){
    182                 window['_fs_host'] = 'fullstory.com';
    183                 window['_fs_script'] = 'edge.fullstory.com/s/fs.js';
    184                 window['_fs_org'] = 'o-1ESJKB-na1';
    185                 window['_fs_namespace'] = 'FS';
    186                 (function(m,n,e,t,l,o,g,y){
    187                     if (e in m) {if(m.console && m.console.log) { m.console.log('FullStory namespace conflict. Please set window["_fs_namespace"].');} return;}
    188                     g=m[e]=function(a,b,s){g.q?g.q.push([a,b,s]):g._api(a,b,s);};g.q=[];
    189                     o=n.createElement(t);o.async=1;o.crossOrigin='anonymous';o.src='https://'+_fs_script;
    190                     y=n.getElementsByTagName(t)[0];y.parentNode.insertBefore(o,y);
    191                     g.identify=function(i,v,s){g(l,{uid:i},s);if(v)g(l,v,s)};g.setUserVars=function(v,s){g(l,v,s)};g.event=function(i,v,s){g('event',{n:i,p:v},s)};
    192                     g.anonymize=function(){g.identify(!!0)};
    193                     g.shutdown=function(){g("rec",!1)};g.restart=function(){g("rec",!0)};
    194                     g.log = function(a,b){g("log",[a,b])};
    195                     g.consent=function(a){g("consent",!arguments.length||a)};
    196                     g.identifyAccount=function(i,v){o='account';v=v||{};v.acctId=i;g(o,v)};
    197                     g.clearUserCookie=function(){};
    198                     g.setVars=function(n, p){g('setVars',[n,p]);};
    199                     g._w={};y='XMLHttpRequest';g._w[y]=m[y];y='fetch';g._w[y]=m[y];
    200                     if(m[y])m[y]=function(){return g._w[y].apply(this,arguments)};
    201                     g._v="1.3.0";
    202                 })(window,document,window['_fs_namespace'],'script','user');
    203             }
     182            // Set buyer email
     183            buyer_email = $('#billing_email').val();
     184
     185            // // Exclude Sprinque domains from the fullstory
     186            // let hostname = window.location.hostname;
     187            // if(hostname !== 'sprinque.wp-masters.com' && hostname !== 'wp-demo.sprinque.com'){
     188            //     window['_fs_host'] = 'fullstory.com';
     189            //     window['_fs_script'] = 'edge.fullstory.com/s/fs.js';
     190            //     window['_fs_org'] = 'o-1ESJKB-na1';
     191            //     window['_fs_namespace'] = 'FS';
     192            //     (function(m,n,e,t,l,o,g,y){
     193            //         if (e in m) {if(m.console && m.console.log) { m.console.log('FullStory namespace conflict. Please set window["_fs_namespace"].');} return;}
     194            //         g=m[e]=function(a,b,s){g.q?g.q.push([a,b,s]):g._api(a,b,s);};g.q=[];
     195            //         o=n.createElement(t);o.async=1;o.crossOrigin='anonymous';o.src='https://'+_fs_script;
     196            //         y=n.getElementsByTagName(t)[0];y.parentNode.insertBefore(o,y);
     197            //         g.identify=function(i,v,s){g(l,{uid:i},s);if(v)g(l,v,s)};g.setUserVars=function(v,s){g(l,v,s)};g.event=function(i,v,s){g('event',{n:i,p:v},s)};
     198            //         g.anonymize=function(){g.identify(!!0)};
     199            //         g.shutdown=function(){g("rec",!1)};g.restart=function(){g("rec",!0)};
     200            //         g.log = function(a,b){g("log",[a,b])};
     201            //         g.consent=function(a){g("consent",!arguments.length||a)};
     202            //         g.identifyAccount=function(i,v){o='account';v=v||{};v.acctId=i;g(o,v)};
     203            //         g.clearUserCookie=function(){};
     204            //         g.setVars=function(n, p){g('setVars',[n,p]);};
     205            //         g._w={};y='XMLHttpRequest';g._w[y]=m[y];y='fetch';g._w[y]=m[y];
     206            //         if(m[y])m[y]=function(){return g._w[y].apply(this,arguments)};
     207            //         g._v="1.3.0";
     208            //     })(window,document,window['_fs_namespace'],'script','user');
     209            // }
    204210
    205211        }
     
    271277            if($(this).val() == country) {
    272278                $('#select_country_pay').wpmSelect('setVal', country);
     279                $('#company_name_pay').val($('#billing_company').val());
    273280            }
    274281        });
     
    385392
    386393    });
    387 
    388     var buyer_email;
    389     var merchant_buyer_id;
    390394
    391395    $("body").on("click", "#register_buyer_company", function(event) {
     
    441445                        }
    442446                    } else {
    443                         $('.error-register-fields').html(response.message).show();
     447                        let errorMessages = response.message;
     448                        if ('response' in response && 'errors' in response.response) {
     449                            errorMessages += searchAdditionalErrorHandler(response.response.errors)
     450                        }
     451
     452                        $('.error-confirm-order').html(errorMessages).show();
    444453                    }
    445454                }
     
    568577                        }
    569578                    } else {
    570                         $('.error-confirm-order').show().html(response.message);
     579                        let errorMessages = response.message;
     580                        if ('response' in response && 'errors' in response.response) {
     581                            errorMessages += searchAdditionalErrorHandler(response.response.errors)
     582                        }
     583
     584                        $('.error-confirm-order').show().html(errorMessages);
    571585                    }
    572586                }
     
    576590        }
    577591    });
     592
     593    function searchAdditionalErrorHandler(data) {
     594        let resultHtml = '';
     595
     596        try {
     597            for (let key in data) {
     598                data[key].forEach(errors => {
     599                    for (let field in errors) {
     600                        errors[field].forEach(message => {
     601                            resultHtml += '<p>' + message + '</p>';
     602                        });
     603                    }
     604                });
     605            }
     606        } catch (e) {
     607            console.log(e);
     608        }
     609
     610        return resultHtml;
     611    }
    578612
    579613    function verify_company() {
     
    786820        var search_by = $('input[name="search_by"]:checked').val();
    787821
    788         if(country_code.length > 0 && company_name.length > 1 && !orderPayed) {
     822        if(country_code.length > 0 && company_name.length > 2 && !orderPayed) {
    789823
    790824            $('.search-company-result').addClass('search-company-result_loading');
  • sprinque/trunk/include/payment_method.php

    r2849683 r2852878  
    2727add_action( 'wp_ajax_nopriv_sprinque_register_buyer', 'sprinque_register_buyer_api', 99 );
    2828
    29 add_action( 'wp_ajax_sprinque_get_business_details', 'sprinque_get_business_details', 99 );
    30 add_action( 'wp_ajax_nopriv_sprinque_get_business_details', 'sprinque_get_business_details', 99 );
    31 
    3229add_action( 'wp_ajax_sprinque_get_countries_api', 'sprinque_get_countries_api', 99 );
    3330add_action( 'wp_ajax_nopriv_sprinque_get_countries_api', 'sprinque_get_countries_api', 99 );
     
    3936    $SrinquePay = new WPM_SrinquePay;
    4037    $SrinquePay->sprinque_get_buyer_info();
    41 }
    42 
    43 /**
    44  * Get Buyer Info
    45  */
    46 function sprinque_get_business_details() {
    47     $SrinquePay = new WPM_SrinquePay;
    48     $SrinquePay->sprinque_get_business_details();
    4938}
    5039
     
    170159
    171160            include( PLUGIN_SRINQUE_DIR . '/templates/frontend/srinque_pay_modal_form.php' );
    172         }
    173 
    174         /**
    175          * Get List Sprinque companies
    176          */
    177         public function sprinque_get_business_details() {
    178             if (! isset( $_POST['country_code'] ) || ! isset( $_POST['registration_number'] ) ) {
    179                 return false;
    180             }
    181 
    182             $data = [
    183                 'country_code'        => sanitize_text_field($_POST['country_code']),
    184                 'registration_number' => sanitize_text_field($_POST['registration_number'])
    185             ];
    186 
    187             $business = $this->srinque_api( $data, 'POST', '/search/business/details' );
    188 
    189             ob_start();
    190             include( PLUGIN_SRINQUE_DIR . '/templates/ajax/company_item.php' );
    191             $result = ob_get_clean();
    192 
    193             wp_send_json( [
    194                 'status'  => 'true',
    195                 'html'    => $result
    196             ] );
    197161        }
    198162
  • sprinque/trunk/languages/sprinque.po

    r2849683 r2852878  
    117117msgstr ""
    118118
    119 msgid "Company name"
    120 msgstr ""
    121 
     119#: templates/frontend/srinque_pay_modal_form.php:31
    122120msgid "VAT ID"
     121msgstr ""
     122
     123#: templates/frontend/srinque_pay_modal_form.php:29
     124msgid "Company VAT ID"
    123125msgstr ""
    124126
     
    180182#: templates/frontend/srinque_pay_modal_form.php:21
    181183#: templates/frontend/srinque_pay_modal_form.php:22
     184#: templates/frontend/srinque_pay_modal_form.php:24
     185#: templates/frontend/srinque_pay_modal_form.php:26
    182186msgid "Company Name"
    183187msgstr ""
  • sprinque/trunk/languages/sprinque.pot

    r2849683 r2852878  
    6161msgstr ""
    6262
    63 msgid "Company name"
    64 msgstr ""
    65 
     63#: templates/frontend/srinque_pay_modal_form.php:31
    6664msgid "VAT ID"
     65msgstr ""
     66
     67#: templates/frontend/srinque_pay_modal_form.php:29
     68msgid "Company VAT ID"
    6769msgstr ""
    6870
     
    109111#: templates/frontend/srinque_pay_modal_form.php:21
    110112#: templates/frontend/srinque_pay_modal_form.php:22
     113#: templates/frontend/srinque_pay_modal_form.php:24
     114#: templates/frontend/srinque_pay_modal_form.php:26
    111115msgid "Company Name"
    112116msgstr ""
  • sprinque/trunk/readme.txt

    r2849745 r2852878  
    66Tested up to: 6.0
    77Requires PHP: 5.3
    8 Stable tag: 1.2.2
     8Stable tag: 1.2.3
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    5050
    5151== Changelog ==
     52
     53= 1.2.3 - January 20, 2023 =
     54* Fixed save-checkout-fields-issue;
     55* Block search for less than 2 characters;
     56* The API errors have been displayed;
     57* Search to be executed when the country is changed;
     58* Edit email in the root form is reflected in the sprinque otp;
     59* Delete unused legacy search/business/details;
     60* Fixed vat-id related .po and .pot translations;
     61* Improved the search checkbox quality;
     62* Turned off the fullstory;
     63* Used PLUGIN_SRINQUE_VERSION for styles and js;
    5264
    5365= 1.2.2 - January 17, 2023 =
  • sprinque/trunk/sprinque.php

    r2849745 r2852878  
    55Description: Sprinque for WordPress is a plugin that allows you to offer your business buyers net payment terms (15, 30, 60, 90 days) and thereby grow conversion and retention.
    66Author: Sprinque
    7 Version: 1.2.2
     7Version: 1.2.3
    88Text Domain: sprinque
    99Domain Path: /languages
    1010*/
    1111
     12define( 'PLUGIN_SRINQUE_VERSION', '1.2.3' );
    1213define( 'PLUGIN_SRINQUE_DIR', __DIR__ );
    1314define( 'PLUGIN_SRINQUE_PATH', plugins_url( '', __FILE__ ) );
     
    6263        // WebHook functions
    6364        add_action( 'init', [ $this, 'get_webhook_response' ], 99 );
    64         add_action( 'init', [ $this, 'save_checkout_fields' ], 99 );
     65        add_action( 'woocommerce_checkout_update_order_review', [ $this, 'save_checkout_fields' ], 99 );
    6566
    6667        // Orders and cart
     
    243244     */
    244245    public function save_checkout_fields() {
    245         if (isset( $_POST['post_data'])) {
    246             // Get Form data from Checkout
    247             $form_data = explode( '&', sanitize_text_field( $_POST['post_data'] ) );
    248             $filtered  = [];
    249 
    250             // Prepare Array
    251             foreach ( $form_data as $value ) {
    252                 $sliced                 = explode( '=', $value );
    253                 $filtered[ $sliced[0] ] = $sliced[1];
    254             }
    255 
    256             // Set Customer Billing Data
    257             $this->setCustomerBillingData($filtered);
    258 
    259             // Set Customer Shipping Data
    260             $this->setCustomerShippingData($filtered);
    261         }
     246        // Get Form data from Checkout
     247        $form_data = explode( '&', sanitize_text_field( $_POST['post_data'] ) );
     248        $filtered  = [];
     249
     250        // Prepare Array
     251        foreach ( $form_data as $value ) {
     252            $sliced                 = explode( '=', $value );
     253            $filtered[ $sliced[0] ] = $sliced[1];
     254        }
     255
     256        // Set Customer Billing Data
     257        $this->setCustomerBillingData($filtered);
     258
     259        // Set Customer Shipping Data
     260        $this->setCustomerShippingData($filtered);
    262261    }
    263262
     
    443442                    // Prepare Data to Send
    444443                    $data = [
    445                         'merchant_order_id' =>  $order_id_from_sequential_plugin ?: $order->get_id(),
     444                        'merchant_order_id' =>  ( $order_id_from_sequential_plugin ?: $order->get_id() ) . '_wh',
    446445                        'order_amount'      => $order->get_total(),
    447446                        'shipping_address'  => [
     
    559558    public function include_scripts_and_styles() {
    560559        // Register styles
    561         wp_enqueue_style( 'wpm_srinque_pay', PLUGIN_SRINQUE_PATH . '/assets/css/frontend.css', false, '1.0.91', 'all' );
     560        wp_enqueue_style( 'wpm_srinque_pay', PLUGIN_SRINQUE_PATH . '/assets/css/frontend.css', false, PLUGIN_SRINQUE_VERSION, 'all' );
    562561
    563562        // Register scripts
    564563        $settings = get_option( 'woocommerce_wpm_srinque_pay_settings', true );
    565         wp_enqueue_script( 'wpm_srinque_pay', PLUGIN_SRINQUE_PATH . '/assets/js/frontend.js', array( 'jquery' ), '1.0.91', 'all' );
     564        wp_enqueue_script( 'wpm_srinque_pay', PLUGIN_SRINQUE_PATH . '/assets/js/frontend.js', array( 'jquery' ), PLUGIN_SRINQUE_VERSION, 'all' );
    566565        wp_localize_script( 'wpm_srinque_pay', 'admin', array(
    567566            'ajaxurl' => admin_url( 'admin-ajax.php' ),
Note: See TracChangeset for help on using the changeset viewer.