Plugin Directory

Changeset 2919599


Ignore:
Timestamp:
05/31/2023 11:15:13 AM (3 years ago)
Author:
northmule
Message:

Update to version 2.2.5 from GitHub

Location:
buy-one-click-woocommerce
Files:
4 added
28 edited
1 copied

Legend:

Unmodified
Added
Removed
  • buy-one-click-woocommerce/tags/2.2.5/buycli-index.php

    r2864638 r2919599  
    55 * Plugin URI: http://zixn.ru/plagin-zakazat-v-odin-klik-dlya-woocommerce.html
    66 * Description: Buy in one click for WooCommerce. The best plugin that adds to your online store purchase button in one click
    7  * Version: 2.2.4
     7 * Version: 2.2.5
    88 * Author: Djo
    99 * Author URI: https://zixn.ru
  • buy-one-click-woocommerce/tags/2.2.5/js/form.js

    r2774363 r2919599  
    125125    jQuery(document).on('click', 'button.clickBuyButton', function (e) {
    126126        e.preventDefault();
    127         var self = jQuery(this);
     127        let self = jQuery(this);
    128128        if(jQuery(self).hasClass('disabled')){
    129129            return;
    130130        }
    131         var zixnAjaxUrl = getAjaxUrl();
    132         var butObj = 'body';
    133         // var butObj = self.parent();
    134 
    135         var button = jQuery(this);
    136 
    137         var urlpost = window.location.href;
    138         var productid = jQuery(this).attr('data-productid');
    139         var action = 'getViewForm';
    140         var variation_selected = 0;
    141         var variation_attr = '';
     131        let button = jQuery(this);
     132        let urlpost = window.location.href;
     133        let productid = jQuery(this).attr('data-productid');
     134        let action = 'getViewForm';
     135        let variation_selected = 0;
     136        let variation_attr = '';
    142137
    143138        jQuery(button).addClass('running');
     
    153148        jQuery.ajax({
    154149            type: "POST",
    155             url: zixnAjaxUrl,
    156             // async: false,
     150            url: getAjaxUrl(),
    157151            data: {
    158152                action: action,
     
    171165                }
    172166                jQuery('#formOrderOneClick').remove();
    173                 jQuery(butObj).append(response.data);
     167                jQuery('body').append(response.data);
    174168                jQuery('.popup, .overlay').css('opacity', '1');
    175169                jQuery('.popup, .overlay').css('visibility', 'visible');
     
    181175                buyone_click_body_scroll();
    182176                if (typeof buyone_ajax.callback_after_clicking_on_button !== 'undefined') {
    183                     var callback = new Function(buyone_ajax.callback_after_clicking_on_button);
     177                    const callback = new Function(buyone_ajax.callback_after_clicking_on_button);
    184178                    callback();
    185179                }
     180            },
     181            error: function (response) {
     182
    186183            }
    187184        });
     
    221218                buyone_click_body_scroll();
    222219                if (typeof buyone_ajax.callback_after_clicking_on_button !== 'undefined') {
    223                     var callback = new Function(buyone_ajax.callback_after_clicking_on_button);
     220                    const callback = new Function(buyone_ajax.callback_after_clicking_on_button);
    224221                    callback();
    225222                }
  • buy-one-click-woocommerce/tags/2.2.5/readme.txt

    r2864638 r2919599  
    44Tags: woocommerce, ecommerce, mode catalog, buy one click, buy now, add to cart, buy now button, buttons
    55Requires at least: 5.0
    6 Tested up to: 6.1
    7 Stable tag: 5.7
     6Tested up to: 6.2
     7Stable tag: 5.9
    88Requires PHP: 7.4
    9 WC requires at least: 4.7
    10 WC tested up to: 6.1
     9WC requires at least: 5.0
     10WC tested up to: 7.7
    1111License: GPLv2 or later
    1212License URI: http://www.apache.org/licenses/
     
    7373
    7474== Changelog ==
     75= 2.2.5 =
     76* Added polylang support for multilingual sites
     77* Added plugin "Woo Discount Rules" support for product pricing
    7578= 2.2.4 =
    7679* Improved compatibility with the plugin "coderun-buy-one-click-woocommerce-variations"
  • buy-one-click-woocommerce/tags/2.2.5/src/Controller/FormController.php

    r2796162 r2919599  
    1111use Coderun\BuyOneClick\Templates\Elements\Factory\QuantityFactory;
    1212use Coderun\BuyOneClick\Templates\QuickOrderFormFactory;
     13use Coderun\BuyOneClick\Utils\Product as ProductUtils;
    1314
    1415use function add_action;
     
    7374                'productId'        => $product->get_id()?? '',
    7475                'productName'      => $product->get_name()?? '',
    75                 'productPrice'     => $product->get_price() ?? '',
     76                'productPrice'     => ProductUtils::getProductPrice($product),
    7677                'productPriceHtml' => $product->get_price_html() ?? '',
    7778                'productCount'     => 1,
  • buy-one-click-woocommerce/tags/2.2.5/src/Controller/OrderController.php

    r2864638 r2919599  
    2727use Coderun\BuyOneClick\Utils\Hooks;
    2828use Coderun\BuyOneClick\Utils\Sms as SmsUtils;
     29use Coderun\BuyOneClick\Utils\Translation;
    2930use Coderun\BuyOneClick\ValueObject\FieldNameViaType;
    3031use Coderun\BuyOneClick\ValueObject\OrderForm;
     
    168169            $orderResponse = new OrderResponse();
    169170            $orderResponse->setMessage(__('The order has been sent', 'coderun-oneclickwoo'));
    170             $orderResponse->setResult($this->commonOptions->getSubmittingFormMessageSuccess());
     171            $orderResponse->setResult(Translation::translate($this->commonOptions->getSubmittingFormMessageSuccess()));
    171172            $orderResponse->setProducts([new Product($orderForm)]);
    172173            $orderResponse->setOrderUuid($orderForm->getOrderUuid());
  • buy-one-click-woocommerce/tags/2.2.5/src/Core.php

    r2864638 r2919599  
    66use Coderun\BuyOneClick\Constant\Pages;
    77use Coderun\BuyOneClick\Constant\ShortCodes as ShortCodesConst;
     8use Coderun\BuyOneClick\Constant\TranslationString;
    89use Coderun\BuyOneClick\Controller\Factory\AdminControllerFactory;
    910use Coderun\BuyOneClick\Controller\Factory\CartControllerFactory;
     
    1718use Coderun\BuyOneClick\Service\Factory\ShortCodesFactory;
    1819use Coderun\BuyOneClick\Utils\Hooks;
     20use Coderun\BuyOneClick\Utils\Translation;
    1921use Exception;
    2022use WC_Product;
     
    139141        add_action(
    140142            'init',
     143            [Translation::class, 'registrationTranslate']
     144        );
     145        add_action(
     146            'init',
     147            function (): void {
     148                Translation::registrationTranslateByOptions($this->commonOptions);
     149            }
     150        );
     151        add_action(
     152            'init',
    141153            function (): void {
    142154                do_action('buy_one_click_woocommerce_start_load_core');
     
    189201            }
    190202        );
     203        add_filter('gettext', function ($translation, $text, $domain) {
     204            if ($domain !== 'coderun-oneclickwoo' || !function_exists('pll__')) {
     205                return $translation;
     206            }
     207            if (!in_array($text, TranslationString::all())) {
     208                return $translation;
     209            }
     210            return Translation::translate($text);
     211        }, 10, 3);
    191212    }
    192213
     
    313334                $variables['after_submit_form'] = $this->commonOptions->getUrlRedirectAddress(); // 4  Редирект на страницу после нажатия на кнопку в форме
    314335            }
    315             $variables['after_message_form'] = $this->commonOptions->getSubmittingFormMessageSuccess();
     336            $variables['after_message_form'] = Translation::translate($this->commonOptions->getSubmittingFormMessageSuccess());
    316337        }
    317338        if ($this->marketingOptions->getAfterClickingOnButton()) {
  • buy-one-click-woocommerce/tags/2.2.5/src/Options/General.php

    r2774363 r2919599  
    13671367        return $this;
    13681368    }
     1369   
     1370    /**
     1371     * Поля которые можно переводить
     1372     *
     1373     * @return array
     1374     */
     1375    public function getTextsForTranslation(): array
     1376    {
     1377        return [
     1378            $this->getDescriptionForFieldComment(),
     1379            $this->getDescriptionConsentToProcessing(),
     1380            $this->getDescriptionForFieldEmail(),
     1381            $this->getDescriptionForFieldFiles(),
     1382            $this->getDescriptionForFieldFormatPhone(),
     1383            $this->getDescriptionForFieldName(),
     1384            $this->getDescriptionOfPreOrderButton(),
     1385            $this->getNameButton(),
     1386            $this->getDescriptionForFieldOrderButton(),
     1387            $this->getMessageAfterSubmittingForm(),
     1388            $this->getSubmittingFormMessageSuccess(),
     1389            $this->getFormSubmissionLimitMessage(),
     1390        ];
     1391    }
    13691392}
  • buy-one-click-woocommerce/tags/2.2.5/src/Repository/Order.php

    r2864638 r2919599  
    66use Coderun\BuyOneClick\Hydrator\CommonHydrator;
    77use Coderun\BuyOneClick\Utils\Hooks;
     8use Coderun\BuyOneClick\Utils\Product as ProductUtils;
    89use Exception;
    910use WC_Order;
     
    6869            'variation_id' => $params['product_id'],
    6970            'variation'    => $product->is_type('variation') ? $product->get_attributes() : [],
    70             'subtotal'     => wc_get_price_excluding_tax($product, ['qty' => $params['qty']]),
    71             'total'        => wc_get_price_excluding_tax($product, ['qty' => $params['qty']]),
     71            'subtotal'     => ProductUtils::getProductPrice($product) * intval($params['qty']),
     72            'total'        => ProductUtils::getProductPrice($product) * intval($params['qty']),
    7273            'quantity'     => $params['qty'],
    7374        ];
  • buy-one-click-woocommerce/tags/2.2.5/src/Service/Button.php

    r2864638 r2919599  
    55namespace Coderun\BuyOneClick\Service;
    66
    7 use Coderun\BuyOneClick\Common\ObjectWithConstantState;
    87use Coderun\BuyOneClick\Core;
    98use Coderun\BuyOneClick\Options\General as GeneralOptions;
     
    1413use Coderun\BuyOneClick\Utils\Hooks;
    1514use Coderun\BuyOneClick\Utils\Product as ProductUtils;
     15use Coderun\BuyOneClick\Utils\Translation;
    1616use Exception;
    1717
     
    5252    {
    5353        if ($this->commonOptions->getPositionButton()) {
    54             $name = self::getButtonName();
     54            $name = $this->getButtonName();
    5555            $productId = ProductUtils::getProductId();
    5656            if (isset($params['id']) && !empty($params['id'])) {
     
    108108                        'productName'      => $params->name,
    109109                        'productPriceHtml' => $params->priceWithCurrency,
    110                         'buttonName'       => $this->commonOptions->getNameButton(),
     110                        'buttonName'       => Translation::translate($this->commonOptions->getNameButton()),
    111111                        'inlineStyle'      => '',
    112112                        'inlineScript'     => '',
     
    137137
    138138        if (ProductUtils::getProductId() === 0 || !$this->commonOptions->isEnableWorkWithRemainingItems()) {
    139             return $defaultName;
     139            return Translation::translate($defaultName);
    140140        }
    141141        $stockStatus = get_post_meta(ProductUtils::getProductId(), '_stock_status', true);
     
    144144        //onbackorder - в не выполненом заказе
    145145
    146         return $stockStatus === 'outofstock' ? $name : $defaultName;
     146        return Translation::translate($stockStatus === 'outofstock' ? $name : $defaultName);
    147147    }
    148148   
  • buy-one-click-woocommerce/tags/2.2.5/src/Utils/Product.php

    r2774363 r2919599  
    55namespace Coderun\BuyOneClick\Utils;
    66
     7use Throwable;
    78use WC_Product;
     9
     10use function class_exists;
     11use function is_array;
     12use function method_exists;
    813
    914/**
     
    3035        return $productId;
    3136    }
     37   
     38    /**
     39     * Цена товара с учётом сторонних дополнений
     40     *
     41     * @param     $product
     42     * @param int $quantity
     43     *
     44     * @return mixed|string
     45     */
     46    public static function getProductPrice($product, $quantity = 1)
     47    {
     48        if (!$product instanceof WC_Product) {
     49            return '';
     50        }
     51        $prices = [];
     52        try {
     53            // plugin - Woo Discount Rules
     54            if (class_exists('\Wdr\App\Controllers\ManageDiscount')
     55                && method_exists('Wdr\App\Controllers\ManageDiscount', 'calculateInitialAndDiscountedPrice')) {
     56                $prices = \Wdr\App\Controllers\ManageDiscount::calculateInitialAndDiscountedPrice($product, $quantity);
     57            }
     58        } catch (Throwable $e) {
     59         // ignore errors
     60        }
     61
     62        if (is_array($prices) && !empty($prices['discounted_price'])) {
     63            return $prices['discounted_price'];
     64        }
     65   
     66        return $product->get_price() ?? '';
     67    }
    3268}
  • buy-one-click-woocommerce/tags/2.2.5/templates/forms/customOrderButton.php

    r2774363 r2919599  
    2020        data-price="<?php echo $fields->productPrice; ?>"
    2121        data-priceHtml="<?php echo $fields->productPriceHtml; ?>">
    22     <span><?php echo $fields->buttonName; ?></span>
     22    <span><?php echo \Coderun\BuyOneClick\Utils\Translation::translate($fields->buttonName); ?></span>
    2323    <div style="font-size:14px" class="ld ld-ring ld-cycle"></div>
    2424</button>
  • buy-one-click-woocommerce/tags/2.2.5/templates/forms/file_uploader.php

    r2747271 r2919599  
    1818        <label for="upload_file_form" class="btn btn-tertiary js-labelFile">
    1919            <i class="icon fa fa-check"></i>
    20             <span class="js-fileName"><?php echo $render->getCommonOptions()->getDescriptionForFieldFiles(); ?></span>
     20            <span class="js-fileName"><?php echo \Coderun\BuyOneClick\Utils\Translation::translate($render->getCommonOptions()->getDescriptionForFieldFiles()); ?></span>
    2121        </label>
    2222    </div>
  • buy-one-click-woocommerce/tags/2.2.5/templates/forms/orderButton.php

    r2763482 r2919599  
    1717    data-variation_id="<?php echo $fields->variationId; ?>"
    1818    data-productid="<?php echo $fields->productId; ?>">
    19     <span> <?php echo $fields->buttonName; ?></span>
     19    <span> <?php echo \Coderun\BuyOneClick\Utils\Translation::translate($fields->buttonName); ?></span>
    2020    <div style="font-size:14px" class="ld ld-ring ld-cycle"></div>
    2121</button>
  • buy-one-click-woocommerce/tags/2.2.5/templates/forms/order_form.php

    r2774363 r2919599  
    11<?php
     2
     3use Coderun\BuyOneClick\Utils\Translation;
     4
    25if (!defined('ABSPATH')) {
    36    exit;
     
    1720        <div class="close_order <?php echo $fields->templateStyle ? 'button' : '' ?>">x</div>
    1821        <form id="buyoneclick_form_order" class="b1c-form" method="post" action="#">
    19             <h2><?php echo $commonOptions->getNameButton(); ?></h2>
     22            <h2><?php echo Translation::translate($commonOptions->getNameButton()); ?></h2>
    2023            <?php if ($commonOptions->isEnableProductInformation()) { ?>
    2124                <div class="table-wrap">
     
    5659           
    5760            <?php if ($commonOptions->isEnableFieldWithName()) { ?>
    58                 <input class="buyvalide <?php echo $fields->templateStyle ? 'input-text' : '' ?>" type="text" <?php ?> placeholder="<?php echo $commonOptions->getDescriptionForFieldName(); ?>" name="txtname">
     61                <input class="buyvalide <?php echo $fields->templateStyle ? 'input-text' : '' ?>" type="text" <?php ?> placeholder="<?php echo Translation::translate($commonOptions->getDescriptionForFieldName()); ?>" name="txtname">
    5962            <?php } ?>
    6063            <?php if ($commonOptions->isEnableFieldWithPhone()) { ?>
    61                 <input class="buyvalide <?php echo $fields->templateStyle ? 'input-text' : '' ?> " type="tel" <?php ?> placeholder="<?php echo $commonOptions->getDescriptionForFieldPhone(); ?>" name="txtphone">
     64                <input class="buyvalide <?php echo $fields->templateStyle ? 'input-text' : '' ?> " type="tel" <?php ?> placeholder="<?php echo Translation::translate($commonOptions->getDescriptionForFieldPhone()); ?>" name="txtphone">
    6265                <p class="phoneFormat"><?php
    6366                    if (!empty($commonOptions->getDescriptionForFieldFormatPhone())) {
     
    6770            <?php } ?>
    6871            <?php if ($commonOptions->isEnableFieldWithEmail()) { ?>
    69                 <input class="buyvalide <?php echo $fields->templateStyle ? 'input-text' : '' ?> " type="email" <?php ?> placeholder="<?php echo $commonOptions->getDescriptionForFieldEmail(); ?>" name="txtemail">
     72                <input class="buyvalide <?php echo $fields->templateStyle ? 'input-text' : '' ?> " type="email" <?php ?> placeholder="<?php echo Translation::translate($commonOptions->getDescriptionForFieldEmail()); ?>" name="txtemail">
    7073            <?php } ?>
    7174            <?php if ($commonOptions->isEnableFieldWithComment()) { ?>
    72                 <textarea class="buymessage buyvalide" <?php ?> name="message" placeholder="<?php echo $commonOptions->getDescriptionForFieldComment(); ?>" rows="2" value=""></textarea>
     75                <textarea class="buymessage buyvalide" <?php ?> name="message" placeholder="<?php echo Translation::translate($commonOptions->getDescriptionForFieldComment()); ?>" rows="2" value=""></textarea>
    7376            <?php } ?>
    7477           
     
    7679                <p>
    7780                    <input type="checkbox" name="conset_personal_data">
    78                     <?php echo $commonOptions->getDescriptionConsentToProcessing(); ?>
     81                    <?php echo Translation::translate($commonOptions->getDescriptionConsentToProcessing()); ?>
    7982                </p>
    8083            <?php } ?>
     
    105108                class="button alt buyButtonOkForm ld-ext-left"
    106109                name="btnsend">
    107                 <span> <?php echo $commonOptions->getDescriptionForFieldOrderButton(); ?></span>
     110                <span> <?php echo Translation::translate($commonOptions->getDescriptionForFieldOrderButton()); ?></span>
    108111                <div style="font-size:14px" class="ld ld-ring ld-cycle"></div>
    109112            </button>
     
    118121        <div class = "popummessage">
    119122            <div class="close_message">x</div>
    120             <?php echo $commonOptions->getMessageAfterSubmittingForm();  ?>
     123            <?php echo Translation::translate($commonOptions->getMessageAfterSubmittingForm());  ?>
    121124        </div>
    122125        <?php
  • buy-one-click-woocommerce/trunk/buycli-index.php

    r2864638 r2919599  
    55 * Plugin URI: http://zixn.ru/plagin-zakazat-v-odin-klik-dlya-woocommerce.html
    66 * Description: Buy in one click for WooCommerce. The best plugin that adds to your online store purchase button in one click
    7  * Version: 2.2.4
     7 * Version: 2.2.5
    88 * Author: Djo
    99 * Author URI: https://zixn.ru
  • buy-one-click-woocommerce/trunk/js/form.js

    r2774363 r2919599  
    125125    jQuery(document).on('click', 'button.clickBuyButton', function (e) {
    126126        e.preventDefault();
    127         var self = jQuery(this);
     127        let self = jQuery(this);
    128128        if(jQuery(self).hasClass('disabled')){
    129129            return;
    130130        }
    131         var zixnAjaxUrl = getAjaxUrl();
    132         var butObj = 'body';
    133         // var butObj = self.parent();
    134 
    135         var button = jQuery(this);
    136 
    137         var urlpost = window.location.href;
    138         var productid = jQuery(this).attr('data-productid');
    139         var action = 'getViewForm';
    140         var variation_selected = 0;
    141         var variation_attr = '';
     131        let button = jQuery(this);
     132        let urlpost = window.location.href;
     133        let productid = jQuery(this).attr('data-productid');
     134        let action = 'getViewForm';
     135        let variation_selected = 0;
     136        let variation_attr = '';
    142137
    143138        jQuery(button).addClass('running');
     
    153148        jQuery.ajax({
    154149            type: "POST",
    155             url: zixnAjaxUrl,
    156             // async: false,
     150            url: getAjaxUrl(),
    157151            data: {
    158152                action: action,
     
    171165                }
    172166                jQuery('#formOrderOneClick').remove();
    173                 jQuery(butObj).append(response.data);
     167                jQuery('body').append(response.data);
    174168                jQuery('.popup, .overlay').css('opacity', '1');
    175169                jQuery('.popup, .overlay').css('visibility', 'visible');
     
    181175                buyone_click_body_scroll();
    182176                if (typeof buyone_ajax.callback_after_clicking_on_button !== 'undefined') {
    183                     var callback = new Function(buyone_ajax.callback_after_clicking_on_button);
     177                    const callback = new Function(buyone_ajax.callback_after_clicking_on_button);
    184178                    callback();
    185179                }
     180            },
     181            error: function (response) {
     182
    186183            }
    187184        });
     
    221218                buyone_click_body_scroll();
    222219                if (typeof buyone_ajax.callback_after_clicking_on_button !== 'undefined') {
    223                     var callback = new Function(buyone_ajax.callback_after_clicking_on_button);
     220                    const callback = new Function(buyone_ajax.callback_after_clicking_on_button);
    224221                    callback();
    225222                }
  • buy-one-click-woocommerce/trunk/readme.txt

    r2864638 r2919599  
    44Tags: woocommerce, ecommerce, mode catalog, buy one click, buy now, add to cart, buy now button, buttons
    55Requires at least: 5.0
    6 Tested up to: 6.1
    7 Stable tag: 5.7
     6Tested up to: 6.2
     7Stable tag: 5.9
    88Requires PHP: 7.4
    9 WC requires at least: 4.7
    10 WC tested up to: 6.1
     9WC requires at least: 5.0
     10WC tested up to: 7.7
    1111License: GPLv2 or later
    1212License URI: http://www.apache.org/licenses/
     
    7373
    7474== Changelog ==
     75= 2.2.5 =
     76* Added polylang support for multilingual sites
     77* Added plugin "Woo Discount Rules" support for product pricing
    7578= 2.2.4 =
    7679* Improved compatibility with the plugin "coderun-buy-one-click-woocommerce-variations"
  • buy-one-click-woocommerce/trunk/src/Controller/FormController.php

    r2796162 r2919599  
    1111use Coderun\BuyOneClick\Templates\Elements\Factory\QuantityFactory;
    1212use Coderun\BuyOneClick\Templates\QuickOrderFormFactory;
     13use Coderun\BuyOneClick\Utils\Product as ProductUtils;
    1314
    1415use function add_action;
     
    7374                'productId'        => $product->get_id()?? '',
    7475                'productName'      => $product->get_name()?? '',
    75                 'productPrice'     => $product->get_price() ?? '',
     76                'productPrice'     => ProductUtils::getProductPrice($product),
    7677                'productPriceHtml' => $product->get_price_html() ?? '',
    7778                'productCount'     => 1,
  • buy-one-click-woocommerce/trunk/src/Controller/OrderController.php

    r2864638 r2919599  
    2727use Coderun\BuyOneClick\Utils\Hooks;
    2828use Coderun\BuyOneClick\Utils\Sms as SmsUtils;
     29use Coderun\BuyOneClick\Utils\Translation;
    2930use Coderun\BuyOneClick\ValueObject\FieldNameViaType;
    3031use Coderun\BuyOneClick\ValueObject\OrderForm;
     
    168169            $orderResponse = new OrderResponse();
    169170            $orderResponse->setMessage(__('The order has been sent', 'coderun-oneclickwoo'));
    170             $orderResponse->setResult($this->commonOptions->getSubmittingFormMessageSuccess());
     171            $orderResponse->setResult(Translation::translate($this->commonOptions->getSubmittingFormMessageSuccess()));
    171172            $orderResponse->setProducts([new Product($orderForm)]);
    172173            $orderResponse->setOrderUuid($orderForm->getOrderUuid());
  • buy-one-click-woocommerce/trunk/src/Core.php

    r2864638 r2919599  
    66use Coderun\BuyOneClick\Constant\Pages;
    77use Coderun\BuyOneClick\Constant\ShortCodes as ShortCodesConst;
     8use Coderun\BuyOneClick\Constant\TranslationString;
    89use Coderun\BuyOneClick\Controller\Factory\AdminControllerFactory;
    910use Coderun\BuyOneClick\Controller\Factory\CartControllerFactory;
     
    1718use Coderun\BuyOneClick\Service\Factory\ShortCodesFactory;
    1819use Coderun\BuyOneClick\Utils\Hooks;
     20use Coderun\BuyOneClick\Utils\Translation;
    1921use Exception;
    2022use WC_Product;
     
    139141        add_action(
    140142            'init',
     143            [Translation::class, 'registrationTranslate']
     144        );
     145        add_action(
     146            'init',
     147            function (): void {
     148                Translation::registrationTranslateByOptions($this->commonOptions);
     149            }
     150        );
     151        add_action(
     152            'init',
    141153            function (): void {
    142154                do_action('buy_one_click_woocommerce_start_load_core');
     
    189201            }
    190202        );
     203        add_filter('gettext', function ($translation, $text, $domain) {
     204            if ($domain !== 'coderun-oneclickwoo' || !function_exists('pll__')) {
     205                return $translation;
     206            }
     207            if (!in_array($text, TranslationString::all())) {
     208                return $translation;
     209            }
     210            return Translation::translate($text);
     211        }, 10, 3);
    191212    }
    192213
     
    313334                $variables['after_submit_form'] = $this->commonOptions->getUrlRedirectAddress(); // 4  Редирект на страницу после нажатия на кнопку в форме
    314335            }
    315             $variables['after_message_form'] = $this->commonOptions->getSubmittingFormMessageSuccess();
     336            $variables['after_message_form'] = Translation::translate($this->commonOptions->getSubmittingFormMessageSuccess());
    316337        }
    317338        if ($this->marketingOptions->getAfterClickingOnButton()) {
  • buy-one-click-woocommerce/trunk/src/Options/General.php

    r2774363 r2919599  
    13671367        return $this;
    13681368    }
     1369   
     1370    /**
     1371     * Поля которые можно переводить
     1372     *
     1373     * @return array
     1374     */
     1375    public function getTextsForTranslation(): array
     1376    {
     1377        return [
     1378            $this->getDescriptionForFieldComment(),
     1379            $this->getDescriptionConsentToProcessing(),
     1380            $this->getDescriptionForFieldEmail(),
     1381            $this->getDescriptionForFieldFiles(),
     1382            $this->getDescriptionForFieldFormatPhone(),
     1383            $this->getDescriptionForFieldName(),
     1384            $this->getDescriptionOfPreOrderButton(),
     1385            $this->getNameButton(),
     1386            $this->getDescriptionForFieldOrderButton(),
     1387            $this->getMessageAfterSubmittingForm(),
     1388            $this->getSubmittingFormMessageSuccess(),
     1389            $this->getFormSubmissionLimitMessage(),
     1390        ];
     1391    }
    13691392}
  • buy-one-click-woocommerce/trunk/src/Repository/Order.php

    r2864638 r2919599  
    66use Coderun\BuyOneClick\Hydrator\CommonHydrator;
    77use Coderun\BuyOneClick\Utils\Hooks;
     8use Coderun\BuyOneClick\Utils\Product as ProductUtils;
    89use Exception;
    910use WC_Order;
     
    6869            'variation_id' => $params['product_id'],
    6970            'variation'    => $product->is_type('variation') ? $product->get_attributes() : [],
    70             'subtotal'     => wc_get_price_excluding_tax($product, ['qty' => $params['qty']]),
    71             'total'        => wc_get_price_excluding_tax($product, ['qty' => $params['qty']]),
     71            'subtotal'     => ProductUtils::getProductPrice($product) * intval($params['qty']),
     72            'total'        => ProductUtils::getProductPrice($product) * intval($params['qty']),
    7273            'quantity'     => $params['qty'],
    7374        ];
  • buy-one-click-woocommerce/trunk/src/Service/Button.php

    r2864638 r2919599  
    55namespace Coderun\BuyOneClick\Service;
    66
    7 use Coderun\BuyOneClick\Common\ObjectWithConstantState;
    87use Coderun\BuyOneClick\Core;
    98use Coderun\BuyOneClick\Options\General as GeneralOptions;
     
    1413use Coderun\BuyOneClick\Utils\Hooks;
    1514use Coderun\BuyOneClick\Utils\Product as ProductUtils;
     15use Coderun\BuyOneClick\Utils\Translation;
    1616use Exception;
    1717
     
    5252    {
    5353        if ($this->commonOptions->getPositionButton()) {
    54             $name = self::getButtonName();
     54            $name = $this->getButtonName();
    5555            $productId = ProductUtils::getProductId();
    5656            if (isset($params['id']) && !empty($params['id'])) {
     
    108108                        'productName'      => $params->name,
    109109                        'productPriceHtml' => $params->priceWithCurrency,
    110                         'buttonName'       => $this->commonOptions->getNameButton(),
     110                        'buttonName'       => Translation::translate($this->commonOptions->getNameButton()),
    111111                        'inlineStyle'      => '',
    112112                        'inlineScript'     => '',
     
    137137
    138138        if (ProductUtils::getProductId() === 0 || !$this->commonOptions->isEnableWorkWithRemainingItems()) {
    139             return $defaultName;
     139            return Translation::translate($defaultName);
    140140        }
    141141        $stockStatus = get_post_meta(ProductUtils::getProductId(), '_stock_status', true);
     
    144144        //onbackorder - в не выполненом заказе
    145145
    146         return $stockStatus === 'outofstock' ? $name : $defaultName;
     146        return Translation::translate($stockStatus === 'outofstock' ? $name : $defaultName);
    147147    }
    148148   
  • buy-one-click-woocommerce/trunk/src/Utils/Product.php

    r2774363 r2919599  
    55namespace Coderun\BuyOneClick\Utils;
    66
     7use Throwable;
    78use WC_Product;
     9
     10use function class_exists;
     11use function is_array;
     12use function method_exists;
    813
    914/**
     
    3035        return $productId;
    3136    }
     37   
     38    /**
     39     * Цена товара с учётом сторонних дополнений
     40     *
     41     * @param     $product
     42     * @param int $quantity
     43     *
     44     * @return mixed|string
     45     */
     46    public static function getProductPrice($product, $quantity = 1)
     47    {
     48        if (!$product instanceof WC_Product) {
     49            return '';
     50        }
     51        $prices = [];
     52        try {
     53            // plugin - Woo Discount Rules
     54            if (class_exists('\Wdr\App\Controllers\ManageDiscount')
     55                && method_exists('Wdr\App\Controllers\ManageDiscount', 'calculateInitialAndDiscountedPrice')) {
     56                $prices = \Wdr\App\Controllers\ManageDiscount::calculateInitialAndDiscountedPrice($product, $quantity);
     57            }
     58        } catch (Throwable $e) {
     59         // ignore errors
     60        }
     61
     62        if (is_array($prices) && !empty($prices['discounted_price'])) {
     63            return $prices['discounted_price'];
     64        }
     65   
     66        return $product->get_price() ?? '';
     67    }
    3268}
  • buy-one-click-woocommerce/trunk/templates/forms/customOrderButton.php

    r2774363 r2919599  
    2020        data-price="<?php echo $fields->productPrice; ?>"
    2121        data-priceHtml="<?php echo $fields->productPriceHtml; ?>">
    22     <span><?php echo $fields->buttonName; ?></span>
     22    <span><?php echo \Coderun\BuyOneClick\Utils\Translation::translate($fields->buttonName); ?></span>
    2323    <div style="font-size:14px" class="ld ld-ring ld-cycle"></div>
    2424</button>
  • buy-one-click-woocommerce/trunk/templates/forms/file_uploader.php

    r2747271 r2919599  
    1818        <label for="upload_file_form" class="btn btn-tertiary js-labelFile">
    1919            <i class="icon fa fa-check"></i>
    20             <span class="js-fileName"><?php echo $render->getCommonOptions()->getDescriptionForFieldFiles(); ?></span>
     20            <span class="js-fileName"><?php echo \Coderun\BuyOneClick\Utils\Translation::translate($render->getCommonOptions()->getDescriptionForFieldFiles()); ?></span>
    2121        </label>
    2222    </div>
  • buy-one-click-woocommerce/trunk/templates/forms/orderButton.php

    r2763482 r2919599  
    1717    data-variation_id="<?php echo $fields->variationId; ?>"
    1818    data-productid="<?php echo $fields->productId; ?>">
    19     <span> <?php echo $fields->buttonName; ?></span>
     19    <span> <?php echo \Coderun\BuyOneClick\Utils\Translation::translate($fields->buttonName); ?></span>
    2020    <div style="font-size:14px" class="ld ld-ring ld-cycle"></div>
    2121</button>
  • buy-one-click-woocommerce/trunk/templates/forms/order_form.php

    r2774363 r2919599  
    11<?php
     2
     3use Coderun\BuyOneClick\Utils\Translation;
     4
    25if (!defined('ABSPATH')) {
    36    exit;
     
    1720        <div class="close_order <?php echo $fields->templateStyle ? 'button' : '' ?>">x</div>
    1821        <form id="buyoneclick_form_order" class="b1c-form" method="post" action="#">
    19             <h2><?php echo $commonOptions->getNameButton(); ?></h2>
     22            <h2><?php echo Translation::translate($commonOptions->getNameButton()); ?></h2>
    2023            <?php if ($commonOptions->isEnableProductInformation()) { ?>
    2124                <div class="table-wrap">
     
    5659           
    5760            <?php if ($commonOptions->isEnableFieldWithName()) { ?>
    58                 <input class="buyvalide <?php echo $fields->templateStyle ? 'input-text' : '' ?>" type="text" <?php ?> placeholder="<?php echo $commonOptions->getDescriptionForFieldName(); ?>" name="txtname">
     61                <input class="buyvalide <?php echo $fields->templateStyle ? 'input-text' : '' ?>" type="text" <?php ?> placeholder="<?php echo Translation::translate($commonOptions->getDescriptionForFieldName()); ?>" name="txtname">
    5962            <?php } ?>
    6063            <?php if ($commonOptions->isEnableFieldWithPhone()) { ?>
    61                 <input class="buyvalide <?php echo $fields->templateStyle ? 'input-text' : '' ?> " type="tel" <?php ?> placeholder="<?php echo $commonOptions->getDescriptionForFieldPhone(); ?>" name="txtphone">
     64                <input class="buyvalide <?php echo $fields->templateStyle ? 'input-text' : '' ?> " type="tel" <?php ?> placeholder="<?php echo Translation::translate($commonOptions->getDescriptionForFieldPhone()); ?>" name="txtphone">
    6265                <p class="phoneFormat"><?php
    6366                    if (!empty($commonOptions->getDescriptionForFieldFormatPhone())) {
     
    6770            <?php } ?>
    6871            <?php if ($commonOptions->isEnableFieldWithEmail()) { ?>
    69                 <input class="buyvalide <?php echo $fields->templateStyle ? 'input-text' : '' ?> " type="email" <?php ?> placeholder="<?php echo $commonOptions->getDescriptionForFieldEmail(); ?>" name="txtemail">
     72                <input class="buyvalide <?php echo $fields->templateStyle ? 'input-text' : '' ?> " type="email" <?php ?> placeholder="<?php echo Translation::translate($commonOptions->getDescriptionForFieldEmail()); ?>" name="txtemail">
    7073            <?php } ?>
    7174            <?php if ($commonOptions->isEnableFieldWithComment()) { ?>
    72                 <textarea class="buymessage buyvalide" <?php ?> name="message" placeholder="<?php echo $commonOptions->getDescriptionForFieldComment(); ?>" rows="2" value=""></textarea>
     75                <textarea class="buymessage buyvalide" <?php ?> name="message" placeholder="<?php echo Translation::translate($commonOptions->getDescriptionForFieldComment()); ?>" rows="2" value=""></textarea>
    7376            <?php } ?>
    7477           
     
    7679                <p>
    7780                    <input type="checkbox" name="conset_personal_data">
    78                     <?php echo $commonOptions->getDescriptionConsentToProcessing(); ?>
     81                    <?php echo Translation::translate($commonOptions->getDescriptionConsentToProcessing()); ?>
    7982                </p>
    8083            <?php } ?>
     
    105108                class="button alt buyButtonOkForm ld-ext-left"
    106109                name="btnsend">
    107                 <span> <?php echo $commonOptions->getDescriptionForFieldOrderButton(); ?></span>
     110                <span> <?php echo Translation::translate($commonOptions->getDescriptionForFieldOrderButton()); ?></span>
    108111                <div style="font-size:14px" class="ld ld-ring ld-cycle"></div>
    109112            </button>
     
    118121        <div class = "popummessage">
    119122            <div class="close_message">x</div>
    120             <?php echo $commonOptions->getMessageAfterSubmittingForm();  ?>
     123            <?php echo Translation::translate($commonOptions->getMessageAfterSubmittingForm());  ?>
    121124        </div>
    122125        <?php
Note: See TracChangeset for help on using the changeset viewer.