mirror of
https://github.com/retailcrm/opencart-module.git
synced 2024-11-25 14:46:06 +03:00
v3.2.4 Отправка нулевой цены при отсутсвтующей акционной цене
This commit is contained in:
parent
6443e10330
commit
8a823cf3ad
@ -1,5 +1,7 @@
|
|||||||
## v.3.2.4
|
## v.3.2.4
|
||||||
* Изменена передача типов цен с учетом групп пользователей на сайте
|
* Добавлена возможность передачи акционных цен для нескольких групп пользователей
|
||||||
|
* Добавлена передача нулевой цены для неустановленных акционных цен
|
||||||
|
* Убрана базовая цена retailcrm из настроек соответствия типов цен
|
||||||
|
|
||||||
## v.3.2.2
|
## v.3.2.2
|
||||||
* Убрана генерация externalId покупателя при заказе без регистрации на сайте.
|
* Убрана генерация externalId покупателя при заказе без регистрации на сайте.
|
||||||
|
@ -45,7 +45,6 @@ class ModelExtensionRetailcrmPrices extends Model
|
|||||||
$retailcrmApiClient->storePricesUpload($priceUpload);
|
$retailcrmApiClient->storePricesUpload($priceUpload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $pricesUpload;
|
return $pricesUpload;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,71 +68,89 @@ class ModelExtensionRetailcrmPrices extends Model
|
|||||||
$specials = $this->model_catalog_product->getProductSpecials($product['product_id']);
|
$specials = $this->model_catalog_product->getProductSpecials($product['product_id']);
|
||||||
|
|
||||||
if (!$specials) {
|
if (!$specials) {
|
||||||
continue;
|
$productPrice = $this->getEmptyPrice();
|
||||||
|
$prices[] = $this->getPriceRequest($product, $site, $productPrice, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$productPrice = array();
|
$productPrice = array();
|
||||||
|
|
||||||
if (is_array($specials) && count($specials)) {
|
if (is_array($specials) && count($specials)) {
|
||||||
$productPrice = $this->getSpecialPrice($specials);
|
$productPrice = ModelExtensionRetailcrmPrices::getSpecialPrice($specials);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($productPrice)) {
|
if (empty($productPrice)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$offers = $this->retailcrm->getOffers($product);
|
$prices[] = $this->getPriceRequest($product, $site, $productPrice);
|
||||||
|
|
||||||
foreach ($offers as $optionsString => $optionsValues) {
|
|
||||||
$optionsString = explode('_', $optionsString);
|
|
||||||
$options = array();
|
|
||||||
|
|
||||||
foreach($optionsString as $optionString) {
|
|
||||||
$option = explode('-', $optionString);
|
|
||||||
$optionIds = explode(':', $option[0]);
|
|
||||||
|
|
||||||
if ($optionString != '0:0-0') {
|
|
||||||
$optionData = $this->getOptionData($optionIds[1], $option[1]);
|
|
||||||
$options[$optionIds[0]] = array(
|
|
||||||
'name' => $optionData['optionName'],
|
|
||||||
'value' => $optionData['optionValue'],
|
|
||||||
'value_id' => $option[1]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ksort($options);
|
|
||||||
|
|
||||||
$offerId = array();
|
|
||||||
|
|
||||||
foreach($options as $optionKey => $optionData) {
|
|
||||||
$offerId[] = $optionKey.'-'.$optionData['value_id'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$offerId = implode('_', $offerId);
|
|
||||||
$price = array();
|
|
||||||
|
|
||||||
foreach($productPrice as $k => $v) {
|
|
||||||
if (isset($this->settings[$this->moduleTitle . '_special_' . $k])) {
|
|
||||||
$price[] = array(
|
|
||||||
'code' => $this->settings[$this->moduleTitle . '_special_' . $k],
|
|
||||||
'price' => $v + $optionsValues['price']
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$prices[] = array(
|
|
||||||
'externalId' => $offerId ? $product['product_id'] . '#' . $offerId : $product['product_id'],
|
|
||||||
'site' => $site,
|
|
||||||
'prices' => $price
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $prices;
|
return $prices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get prices for request
|
||||||
|
*
|
||||||
|
* @param $product
|
||||||
|
* @param $site
|
||||||
|
* @param $specials
|
||||||
|
* @param bool $noSpecials
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function getPriceRequest($product, $site, $productPrice)
|
||||||
|
{
|
||||||
|
$offers = $this->retailcrm->getOffers($product);
|
||||||
|
$pricesProduct = array();
|
||||||
|
|
||||||
|
foreach ($offers as $optionsString => $optionsValues) {
|
||||||
|
$optionsString = explode('_', $optionsString);
|
||||||
|
$options = array();
|
||||||
|
|
||||||
|
foreach($optionsString as $optionString) {
|
||||||
|
$option = explode('-', $optionString);
|
||||||
|
$optionIds = explode(':', $option[0]);
|
||||||
|
|
||||||
|
if ($optionString != '0:0-0') {
|
||||||
|
$optionData = $this->getOptionData($optionIds[1], $option[1]);
|
||||||
|
$options[$optionIds[0]] = array(
|
||||||
|
'name' => $optionData['optionName'],
|
||||||
|
'value' => $optionData['optionValue'],
|
||||||
|
'value_id' => $option[1]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ksort($options);
|
||||||
|
|
||||||
|
$offerId = array();
|
||||||
|
|
||||||
|
foreach($options as $optionKey => $optionData) {
|
||||||
|
$offerId[] = $optionKey.'-'.$optionData['value_id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$offerId = implode('_', $offerId);
|
||||||
|
$price = array();
|
||||||
|
|
||||||
|
foreach($productPrice as $k => $v) {
|
||||||
|
if (isset($this->settings[$this->moduleTitle . '_special_' . $k])) {
|
||||||
|
$price[] = array(
|
||||||
|
'code' => $this->settings[$this->moduleTitle . '_special_' . $k],
|
||||||
|
'price' => $v == 0 ? $v : $v + $optionsValues['price']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$pricesProduct = array(
|
||||||
|
'externalId' => $offerId ? $product['product_id'] . '#' . $offerId : $product['product_id'],
|
||||||
|
'site' => $site,
|
||||||
|
'prices' => $price
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $pricesProduct;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get actual special
|
* Get actual special
|
||||||
*
|
*
|
||||||
@ -166,6 +183,31 @@ class ModelExtensionRetailcrmPrices extends Model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$customerGroups = $this->model_customer_customer_group->getCustomerGroups();
|
||||||
|
|
||||||
|
foreach ($customerGroups as $customerGroup) {
|
||||||
|
if (!isset($productPrice[$customerGroup['customer_group_id']])){
|
||||||
|
$productPrice[$customerGroup['customer_group_id']] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $productPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get price for no special
|
||||||
|
*
|
||||||
|
* @return array $productPrice
|
||||||
|
*/
|
||||||
|
private function getEmptyPrice()
|
||||||
|
{
|
||||||
|
$customerGroups = $this->model_customer_customer_group->getCustomerGroups();
|
||||||
|
$productPrice = array();
|
||||||
|
|
||||||
|
foreach ($customerGroups as $customerGroup) {
|
||||||
|
$productPrice[$customerGroup['customer_group_id']] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return $productPrice;
|
return $productPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@
|
|||||||
<div class="col-md-4 col-sm-10">
|
<div class="col-md-4 col-sm-10">
|
||||||
<select id="retailcrm_special_<?php echo $uid; ?>" name="retailcrm_special_<?php echo $uid; ?>" class="form-control">
|
<select id="retailcrm_special_<?php echo $uid; ?>" name="retailcrm_special_<?php echo $uid; ?>" class="form-control">
|
||||||
<?php foreach ($priceTypes as $k => $priceType): ?>
|
<?php foreach ($priceTypes as $k => $priceType): ?>
|
||||||
<?php if ($priceType['active'] == true) :?>
|
<?php if ($priceType['active'] == true and $priceType['default'] == false) :?>
|
||||||
<option value="<?php echo $priceType['code'];?>" <?php if(isset($saved_settings['retailcrm_special_' . $cid]) && $priceType['code'] == $saved_settings['retailcrm_special_' . $cid]):?>selected="selected"<?php endif;?>>
|
<option value="<?php echo $priceType['code'];?>" <?php if(isset($saved_settings['retailcrm_special_' . $cid]) && $priceType['code'] == $saved_settings['retailcrm_special_' . $cid]):?>selected="selected"<?php endif;?>>
|
||||||
<?php echo $priceType['name'];?>
|
<?php echo $priceType['name'];?>
|
||||||
</option>
|
</option>
|
||||||
|
@ -141,7 +141,7 @@
|
|||||||
<div class="col-md-4 col-sm-10">
|
<div class="col-md-4 col-sm-10">
|
||||||
<select id="module_retailcrm_special_{{ cud }}" name="module_retailcrm_special_{{ cud }}" class="form-control">
|
<select id="module_retailcrm_special_{{ cud }}" name="module_retailcrm_special_{{ cud }}" class="form-control">
|
||||||
{% for priceType in priceTypes %}
|
{% for priceType in priceTypes %}
|
||||||
{% if priceType.active == true %}
|
{% if priceType.active == true and priceType.default == false%}
|
||||||
<option value ="{{ priceType.code }}" {% if saved_settings['module_retailcrm_special_'~cud] is defined and priceType.code == saved_settings['module_retailcrm_special_'~cud] %} selected="selected" {% endif %}>
|
<option value ="{{ priceType.code }}" {% if saved_settings['module_retailcrm_special_'~cud] is defined and priceType.code == saved_settings['module_retailcrm_special_'~cud] %} selected="selected" {% endif %}>
|
||||||
{{ priceType.name }}
|
{{ priceType.name }}
|
||||||
</option>
|
</option>
|
||||||
|
@ -30,7 +30,8 @@ class ModelRetailcrmPricesAdminTest extends OpenCartTest
|
|||||||
array(
|
array(
|
||||||
$this->retailcrm->getModuleTitle() . '_apiversion' => 'v5',
|
$this->retailcrm->getModuleTitle() . '_apiversion' => 'v5',
|
||||||
$this->retailcrm->getModuleTitle() . '_special_1' => 'special1',
|
$this->retailcrm->getModuleTitle() . '_special_1' => 'special1',
|
||||||
$this->retailcrm->getModuleTitle() . '_special_2' => 'special2'
|
$this->retailcrm->getModuleTitle() . '_special_2' => 'special2',
|
||||||
|
$this->retailcrm->getModuleTitle() . '_special_3' => 'special3'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -58,6 +59,10 @@ class ModelRetailcrmPricesAdminTest extends OpenCartTest
|
|||||||
$this->assertArrayHasKey('site', $price);
|
$this->assertArrayHasKey('site', $price);
|
||||||
$this->assertArrayHasKey('prices', $price);
|
$this->assertArrayHasKey('prices', $price);
|
||||||
$this->assertInternalType('array', $price['prices']);
|
$this->assertInternalType('array', $price['prices']);
|
||||||
|
$this->assertEquals('special1', $price['prices'][0]['code']);
|
||||||
|
$this->assertEquals('special2', $price['prices'][1]['code']);
|
||||||
|
$this->assertEquals('special3', $price['prices'][2]['code']);
|
||||||
|
$this->assertEquals(0, $price['prices'][2]['price']);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function sites(){
|
private function sites(){
|
||||||
|
@ -4,9 +4,13 @@ INSERT INTO `oc_customer` (`customer_id`, `customer_group_id`, `store_id`, `lang
|
|||||||
TRUNCATE TABLE `oc_customer_activity`;
|
TRUNCATE TABLE `oc_customer_activity`;
|
||||||
TRUNCATE TABLE `oc_customer_group`;
|
TRUNCATE TABLE `oc_customer_group`;
|
||||||
INSERT INTO `oc_customer_group` (`customer_group_id`, `approval`, `sort_order`) VALUES ('1', '0', '1');
|
INSERT INTO `oc_customer_group` (`customer_group_id`, `approval`, `sort_order`) VALUES ('1', '0', '1');
|
||||||
|
INSERT INTO `oc_customer_group` (`customer_group_id`, `approval`, `sort_order`) VALUES ('2', '0', '1');
|
||||||
|
INSERT INTO `oc_customer_group` (`customer_group_id`, `approval`, `sort_order`) VALUES ('3', '0', '0');
|
||||||
|
|
||||||
TRUNCATE TABLE `oc_customer_group_description`;
|
TRUNCATE TABLE `oc_customer_group_description`;
|
||||||
INSERT INTO `oc_customer_group_description` (`customer_group_id`, `language_id`, `name`, `description`) VALUES ('1', '1', 'Default', 'test');
|
INSERT INTO `oc_customer_group_description` (`customer_group_id`, `language_id`, `name`, `description`) VALUES ('1', '1', 'Default', 'test');
|
||||||
|
INSERT INTO `oc_customer_group_description` (`customer_group_id`, `language_id`, `name`, `description`) VALUES ('2', '1', 'Test2', 'test2');
|
||||||
|
INSERT INTO `oc_customer_group_description` (`customer_group_id`, `language_id`, `name`, `description`) VALUES ('3', '1', 'test3', 'test3');
|
||||||
|
|
||||||
TRUNCATE TABLE `oc_customer_history`;
|
TRUNCATE TABLE `oc_customer_history`;
|
||||||
TRUNCATE TABLE `oc_customer_ip`;
|
TRUNCATE TABLE `oc_customer_ip`;
|
||||||
@ -39,11 +43,13 @@ INSERT INTO `oc_order_product` (`order_product_id`, `order_id`, `product_id`, `n
|
|||||||
TRUNCATE TABLE `oc_order_recurring`;
|
TRUNCATE TABLE `oc_order_recurring`;
|
||||||
TRUNCATE TABLE `oc_order_recurring_transaction`;
|
TRUNCATE TABLE `oc_order_recurring_transaction`;
|
||||||
TRUNCATE TABLE `oc_order_total`;
|
TRUNCATE TABLE `oc_order_total`;
|
||||||
|
|
||||||
INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('162', '1', 'shipping', 'Flat Rate', '5.0000', '3');
|
INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('162', '1', 'shipping', 'Flat Rate', '5.0000', '3');
|
||||||
INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('161', '1', 'sub_total', 'Sub-Total', '101.0000', '1');
|
INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('161', '1', 'sub_total', 'Sub-Total', '101.0000', '1');
|
||||||
INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('164', '2', 'sub_total', 'Sub-Total', '80.0000', '1');
|
INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('164', '2', 'sub_total', 'Sub-Total', '80.0000', '1');
|
||||||
INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('165', '2', 'shipping', 'Flat Rate', '5.0000', '3');
|
INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('165', '2', 'shipping', 'Flat Rate', '5.0000', '3');
|
||||||
INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('163', '1', 'total', 'Total', '106.0000', '9');
|
INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('163', '1', 'total', 'Total', '106.0000', '9');
|
||||||
INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('166', '2', 'total', 'Total', '85.0000', '9');
|
INSERT INTO `oc_order_total` (`order_total_id`, `order_id`, `code`, `title`, `value`, `sort_order`) VALUES ('166', '2', 'total', 'Total', '85.0000', '9');
|
||||||
|
INSERT INTO `oc_product_special` (`product_id`, `customer_group_id`, `priority`, `price`,`date_start`, `date_end`) values ('42', '2', '1', '110.000', CURDATE(), ADDDATE(CURDATE(),INTERVAL 10 DAY));
|
||||||
|
|
||||||
TRUNCATE TABLE `oc_order_voucher`;
|
TRUNCATE TABLE `oc_order_voucher`;
|
Loading…
Reference in New Issue
Block a user