1
0
mirror of synced 2025-01-29 22:31:42 +03:00

Supports custom cart and checkout templates (#353)

This commit is contained in:
Kocmonavtik 2024-11-11 15:08:21 +03:00 committed by GitHub
parent 894c065b99
commit 6e39fca72c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 55 additions and 15 deletions

View File

@ -1,3 +1,6 @@
## 2024-11-07 4.8.13
* Supports custom cart and checkout templates
## 2024-10-24 4.8.12
* Fixed multiple execution of order updates

View File

@ -1 +1 @@
4.8.12
4.8.13

View File

@ -41,6 +41,9 @@ if (!class_exists('WC_Retailcrm_Base')) {
/** @var array */
protected $updatedOrderId = [];
/** @var array */
protected $createdOrderId = [];
/**
* Init and hook in the integration.
*
@ -106,13 +109,14 @@ if (!class_exists('WC_Retailcrm_Base')) {
add_action('wp_print_footer_scripts', [$this, 'initialize_whatsapp'], 101);
add_action('wp_print_footer_scripts', [$this, 'send_analytics'], 99);
add_action('admin_enqueue_scripts', [$this, 'include_files_for_admin'], 101);
add_action('woocommerce_new_order', [$this, 'create_order'], 11, 1);
add_action('woocommerce_new_order', [$this, 'fill_array_create_orders'], 11, 1);
add_action('shutdown', [$this, 'create_order'], -2);
if (
!$this->get_option('deactivate_update_order')
|| $this->get_option('deactivate_update_order') == static::NO
) {
add_action('woocommerce_update_order', [$this, 'take_update_order'], 11, 1);
add_action('woocommerce_update_order', [$this, 'fill_array_update_orders'], 11, 1);
add_action('shutdown', [$this, 'update_order'], -1);
add_action('woocommerce_saved_order_items', [$this, 'update_order_items'], 10, 1);
}
@ -526,6 +530,19 @@ if (!class_exists('WC_Retailcrm_Base')) {
$this->customers->updateCustomer($customerId);
}
public function fill_array_create_orders($order_id)
{
WC_Retailcrm_Logger::setHook(current_action(), $order_id);
if (WC_Retailcrm_Plugin::history_running() === true) {
WC_Retailcrm_Logger::info(__METHOD__, 'History in progress, skip');
return;
}
$this->createdOrderId[$order_id] = $order_id;
}
/**
* Create order in RetailCRM from admin panel
*
@ -533,15 +550,32 @@ if (!class_exists('WC_Retailcrm_Base')) {
*
* @param int $order_id
*/
public function create_order($order_id)
public function create_order()
{
WC_Retailcrm_Logger::setHook(current_action(), $order_id);
WC_Retailcrm_Logger::setHook(current_action());
if (did_action('woocommerce_new_order') === 0) {
return;
}
if (did_action('woocommerce_checkout_order_processed')) {
WC_Retailcrm_Logger::info(
__METHOD__,
'There was a hook woocommerce_checkout_order_processed'
);
return;
}
$logText = 'Creation order';
if (is_admin()) {
WC_Retailcrm_Logger::info(__METHOD__, 'Creation is from admin panel');
$this->retailcrm_process_order($order_id);
} else {
WC_Retailcrm_Logger::info(__METHOD__, 'Creation is not from admin panel, skip');
$logText = 'Creation order from admin panel';
}
foreach ($this->createdOrderId as $orderId) {
WC_Retailcrm_Logger::info(__METHOD__, sprintf('%s (%s)', $logText, $orderId));
$this->retailcrm_process_order($orderId);
}
}
@ -655,7 +689,7 @@ if (!class_exists('WC_Retailcrm_Base')) {
*
* @throws \Exception
*/
public function take_update_order($order_id)
public function fill_array_update_orders($order_id)
{
WC_Retailcrm_Logger::setHook(current_action(), $order_id);
@ -679,8 +713,8 @@ if (!class_exists('WC_Retailcrm_Base')) {
{
WC_Retailcrm_Logger::setHook(current_action());
if ($this->updatedOrderId !== []) {
foreach ($this->updatedOrderId as $orderId) {
foreach ($this->updatedOrderId as $orderId) {
if (!isset($this->createdOrderId[$orderId])) {
$this->orders->updateOrder($orderId);
}
}

View File

@ -5,7 +5,7 @@ Tags: Интеграция, Simla.com, simla
Requires PHP: 7.1
Requires at least: 5.3
Tested up to: 6.5
Stable tag: 4.8.12
Stable tag: 4.8.13
License: GPLv1 or later
License URI: http://www.gnu.org/licenses/gpl-1.0.html
@ -82,6 +82,9 @@ Asegúrate de tener una clave API específica para cada tienda. Las siguientes i
== Changelog ==
= 4.8.13 =
* Supports custom cart and checkout templates
= 4.8.12 =
* Fixed multiple execution of order updates

View File

@ -5,7 +5,7 @@
* Description: Integration plugin for WooCommerce & Simla.com
* Author: RetailDriver LLC
* Author URI: http://retailcrm.pro/
* Version: 4.8.12
* Version: 4.8.13
* Tested up to: 6.5
* Requires Plugins: woocommerce
* WC requires at least: 5.4

View File

@ -16,7 +16,7 @@
*
* @link https://wordpress.org/plugins/woo-retailcrm/
*
* @version 4.8.12
* @version 4.8.13
*
* @package RetailCRM
*/