Plugin Directory

Changeset 2749715


Ignore:
Timestamp:
06/29/2022 02:23:11 PM (4 years ago)
Author:
northmule
Message:

Update to version 2.1.3 from GitHub

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

Legend:

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

    r2747271 r2749715  
    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.1.2
     7 * Version: 2.1.3
    88 * Author: Djo
    99 * Author URI: https://zixn.ru
  • buy-one-click-woocommerce/tags/2.1.3/readme.txt

    r2747271 r2749715  
    7474
    7575== Changelog ==
     76= 2.1.3 =
     77* Fixed the get_customer_unique_id call for older versions of WooCommerce
     78* Checking the restrictions on sending the form redone in the session
    7679= 2.1.2 =
    7780* The order number for yandex.metrica is taken from WooCommerce
  • buy-one-click-woocommerce/tags/2.1.3/src/Controller/OrderController.php

    r2747271 r2749715  
    66
    77use BuySMSC;
    8 use Coderun\BuyOneClick\BuyFunction;
    98use Coderun\BuyOneClick\BuyHookPlugin;
    10 use Coderun\BuyOneClick\Common\Logger;
    119use Coderun\BuyOneClick\Constant\Options\ActionsForm;
    1210use Coderun\BuyOneClick\Core;
     
    2321use Coderun\BuyOneClick\Response\OrderResponse;
    2422use Coderun\BuyOneClick\Response\ValueObject\Product;
     23use Coderun\BuyOneClick\Service\SessionStorage;
    2524use Coderun\BuyOneClick\Utils\Email as EmailUtils;
    2625use Coderun\BuyOneClick\Utils\Sms as SmsUtils;
    2726use Coderun\BuyOneClick\ValueObject\OrderForm;
    2827use WC_Order;
    29 use WC_Session_Handler;
    3028
    3129use function get_current_user_id;
     
    253251    protected function checkLimitSendForm(int $product_id): void
    254252    {
    255         /** @var WC_Session_Handler $session */
    256         $session = WC()->session;
    257253        $commonOptions = Core::getInstance()->getCommonOptions();
    258         $key = sprintf('buy_one_click_woocommerce_%s_%s', $product_id, $session->get_customer_unique_id());
    259         if (!$session->get($key, false)) {//Установка
    260             $session->set($key, time());
     254        $uniqueId = $this->getCustomerUniqueId();
     255        if (empty($uniqueId) || $commonOptions->getFormSubmissionLimit() == 0) {
     256            return;
     257        }
     258        $storage = new SessionStorage();
     259        $key = sprintf('buy_one_%s_%s', $product_id, $uniqueId);
     260        if ($storage->getSessionValue($key) == null) {//Установка
     261            $storage->setSessionValue($key, (time() + $commonOptions->getFormSubmissionLimit()));
    261262        } else {
    262             if (($session->get($key, 0) + $commonOptions->getFormSubmissionLimit()) > time()) {
     263            if ($storage->getSessionValue($key, 0) > time()) {
    263264                throw LimitOnSendingFormsException::error($commonOptions->getFormSubmissionLimitMessage());
    264             }
    265         }
     265            } else {
     266                $storage->deleteSessionKey($key);
     267            }
     268        }
     269        return;
    266270    }
    267271   
     
    282286        return '';
    283287    }
     288
     289    /**
     290     * Уникальный ИД текущего пользователя
     291     *
     292     * @return string
     293     */
     294    protected function getCustomerUniqueId(): string
     295    {
     296        $session = serialize(WC()->session);
     297        preg_match('/(wp_woocommerce_session_[a-zA-Z\d]+)"/i', $session, $matches);
     298        $uniqueString = $matches[1] ?? '';
     299        if (strlen($uniqueString) > 0) {
     300            $uniqueString = md5($uniqueString);
     301        } else if(is_user_logged_in()) {
     302            $uniqueString = (string)get_current_user_id();
     303        }
     304        return $uniqueString;
     305    }
     306
    284307}
  • buy-one-click-woocommerce/tags/2.1.3/src/Core.php

    r2747271 r2749715  
    144144        add_action('woocommerce_email_before_order_table', [Service::getInstance(), 'modificationOrderTemplateWooCommerce'], 10, 3);
    145145        add_action('wp_head', [$this, 'frontVariables']);
     146        add_action('init', static function() {
     147            if (!session_id()) {
     148                session_start();
     149            }
     150        });
    146151        // Обработчики запросов
    147152        $this->initController();
  • buy-one-click-woocommerce/tags/2.1.3/src/Options/General.php

    r2747271 r2749715  
    360360     * @var int
    361361     */
    362     protected int $formSubmissionLimit;
     362    protected int $formSubmissionLimit = 10;
    363363
    364364    /**
  • buy-one-click-woocommerce/trunk/buycli-index.php

    r2747271 r2749715  
    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.1.2
     7 * Version: 2.1.3
    88 * Author: Djo
    99 * Author URI: https://zixn.ru
  • buy-one-click-woocommerce/trunk/readme.txt

    r2747271 r2749715  
    7474
    7575== Changelog ==
     76= 2.1.3 =
     77* Fixed the get_customer_unique_id call for older versions of WooCommerce
     78* Checking the restrictions on sending the form redone in the session
    7679= 2.1.2 =
    7780* The order number for yandex.metrica is taken from WooCommerce
  • buy-one-click-woocommerce/trunk/src/Controller/OrderController.php

    r2747271 r2749715  
    66
    77use BuySMSC;
    8 use Coderun\BuyOneClick\BuyFunction;
    98use Coderun\BuyOneClick\BuyHookPlugin;
    10 use Coderun\BuyOneClick\Common\Logger;
    119use Coderun\BuyOneClick\Constant\Options\ActionsForm;
    1210use Coderun\BuyOneClick\Core;
     
    2321use Coderun\BuyOneClick\Response\OrderResponse;
    2422use Coderun\BuyOneClick\Response\ValueObject\Product;
     23use Coderun\BuyOneClick\Service\SessionStorage;
    2524use Coderun\BuyOneClick\Utils\Email as EmailUtils;
    2625use Coderun\BuyOneClick\Utils\Sms as SmsUtils;
    2726use Coderun\BuyOneClick\ValueObject\OrderForm;
    2827use WC_Order;
    29 use WC_Session_Handler;
    3028
    3129use function get_current_user_id;
     
    253251    protected function checkLimitSendForm(int $product_id): void
    254252    {
    255         /** @var WC_Session_Handler $session */
    256         $session = WC()->session;
    257253        $commonOptions = Core::getInstance()->getCommonOptions();
    258         $key = sprintf('buy_one_click_woocommerce_%s_%s', $product_id, $session->get_customer_unique_id());
    259         if (!$session->get($key, false)) {//Установка
    260             $session->set($key, time());
     254        $uniqueId = $this->getCustomerUniqueId();
     255        if (empty($uniqueId) || $commonOptions->getFormSubmissionLimit() == 0) {
     256            return;
     257        }
     258        $storage = new SessionStorage();
     259        $key = sprintf('buy_one_%s_%s', $product_id, $uniqueId);
     260        if ($storage->getSessionValue($key) == null) {//Установка
     261            $storage->setSessionValue($key, (time() + $commonOptions->getFormSubmissionLimit()));
    261262        } else {
    262             if (($session->get($key, 0) + $commonOptions->getFormSubmissionLimit()) > time()) {
     263            if ($storage->getSessionValue($key, 0) > time()) {
    263264                throw LimitOnSendingFormsException::error($commonOptions->getFormSubmissionLimitMessage());
    264             }
    265         }
     265            } else {
     266                $storage->deleteSessionKey($key);
     267            }
     268        }
     269        return;
    266270    }
    267271   
     
    282286        return '';
    283287    }
     288
     289    /**
     290     * Уникальный ИД текущего пользователя
     291     *
     292     * @return string
     293     */
     294    protected function getCustomerUniqueId(): string
     295    {
     296        $session = serialize(WC()->session);
     297        preg_match('/(wp_woocommerce_session_[a-zA-Z\d]+)"/i', $session, $matches);
     298        $uniqueString = $matches[1] ?? '';
     299        if (strlen($uniqueString) > 0) {
     300            $uniqueString = md5($uniqueString);
     301        } else if(is_user_logged_in()) {
     302            $uniqueString = (string)get_current_user_id();
     303        }
     304        return $uniqueString;
     305    }
     306
    284307}
  • buy-one-click-woocommerce/trunk/src/Core.php

    r2747271 r2749715  
    144144        add_action('woocommerce_email_before_order_table', [Service::getInstance(), 'modificationOrderTemplateWooCommerce'], 10, 3);
    145145        add_action('wp_head', [$this, 'frontVariables']);
     146        add_action('init', static function() {
     147            if (!session_id()) {
     148                session_start();
     149            }
     150        });
    146151        // Обработчики запросов
    147152        $this->initController();
  • buy-one-click-woocommerce/trunk/src/Options/General.php

    r2747271 r2749715  
    360360     * @var int
    361361     */
    362     protected int $formSubmissionLimit;
     362    protected int $formSubmissionLimit = 10;
    363363
    364364    /**
Note: See TracChangeset for help on using the changeset viewer.