From 1861b5255a5ad54b8f71489f5baebcbfe821c2de Mon Sep 17 00:00:00 2001 From: gleemand Date: Wed, 7 Sep 2022 13:19:52 +0300 Subject: [PATCH] Added filter example to doc --- doc/3. Customization/Examples.md | 73 +++++++++++++++----------------- 1 file changed, 35 insertions(+), 38 deletions(-) diff --git a/doc/3. Customization/Examples.md b/doc/3. Customization/Examples.md index d46cb0f..74189d0 100644 --- a/doc/3. Customization/Examples.md +++ b/doc/3. Customization/Examples.md @@ -1,63 +1,28 @@ # Examples - [Classes](#classes) - - [Prices with discounts to icml](#prices-with-discounts-to-icml) + - [Example](#example) - [Filters](#filters) - [Set order custom field on status change](#set-order-custom-field-on-status-change) + - [Prices with discounts to icml](#prices-with-discounts-to-icml) ## Classes -### Prices with discounts to ICML - -Customization for generate ICML catalog with prices including discounts - -Put code to `.../retailcrm/custom/classes/RetailcrmCatalog.php`: +### Example ```php -<...> -$price = !empty($product['rate']) -? round($product['price'], 2) + (round($product['price'], 2) * $product['rate'] / 100) -: round($product['price'], 2); - -// CUSTOMIZATION -$id_group = 0; // All groups -$id_country = 0; // All countries -$id_currency = 0; // All currencies -$id_shop = Shop::getContextShopID(); -$specificPrice = SpecificPrice::getSpecificPrice($product['id_product'], $id_shop, $id_currency, $id_country, $id_group, null); - -if (isset($specificPrice['reduction'])) { - if ($specificPrice['reduction_type'] === 'amount') { - $price = round($price - $specificPrice['reduction'], 2); - } elseif ($specificPrice['reduction_type'] === 'percentage') { - $price = round($price - ($price * $specificPrice['reduction']), 2); - } -} -// END OF CUSTOMIZATION - -if (!empty($product['manufacturer_name'])) { - $vendor = $product['manufacturer_name']; -} else { - $vendor = null; -} -<...> ``` ## Filters ### Set order custom field on status change -Put code to `custom/filters/RetailcrmFilterOrderStatusUpdate.php`: - ```php