Created
January 31, 2022 13:49
-
-
Save danielborzov/47a2f523765a4bd3c71369e8e68331d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app/addons/order_fulfillment/src/HookHandlers/OrdersHookHandler.php b/app/addons/order_fulfillment/src/HookHandlers/OrdersHookHandler.php | |
index 484ba3c6ff..665a827d84 100644 | |
--- a/app/addons/order_fulfillment/src/HookHandlers/OrdersHookHandler.php | |
+++ b/app/addons/order_fulfillment/src/HookHandlers/OrdersHookHandler.php | |
@@ -79,6 +79,17 @@ class OrdersHookHandler | |
if (isset($cart['shippings_extra']['data'][$marketplace_group_key])) { | |
$cart['shippings_extra']['data'][$group_key] = $cart['shippings_extra']['data'][$marketplace_group_key]; | |
} | |
+ | |
+ /** | |
+ * Executes within the 'pre_place_order' hook handler after marketplace shipping method is set to product group, allows managing shipping data for orders with marketplace fulfillment. | |
+ * | |
+ * @param array<string> $cart Cart data | |
+ * @param int $group_key Group key | |
+ * @param int $marketplace_group_key Marketplace group key | |
+ * @param array<string> $chosen_shipping_data Chosen shipping method data | |
+ */ | |
+ fn_set_hook('order_fulfillment_set_marketplace_shipping_to_product_group', $cart, $group_key, $marketplace_group_key, $chosen_shipping_data); | |
+ | |
$is_first_product_group = true; | |
} | |
unset($group); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app/addons/rus_sdek/func.php b/app/addons/rus_sdek/func.php | |
index c6d0104290..69157ab16a 100644 | |
--- a/app/addons/rus_sdek/func.php | |
+++ b/app/addons/rus_sdek/func.php | |
@@ -80,6 +80,7 @@ function fn_rus_sdek_calculate_cart_taxes_pre(&$cart, $cart_products, &$product_ | |
if (!empty($cart['shippings_extra']['data'][$group_key][$shipping_id])) { | |
$shippings_extra = $cart['shippings_extra']['data'][$group_key][$shipping_id]; | |
$product_groups[$group_key]['chosen_shippings'][$shipping_key]['data'] = $shippings_extra; | |
+ | |
if (!empty($select_office[$group_key][$shipping_id])) { | |
$office_id = $select_office[$group_key][$shipping_id]; | |
$product_groups[$group_key]['chosen_shippings'][$shipping_key]['office_id'] = $office_id; | |
@@ -770,3 +771,27 @@ function fn_rus_sdek_place_suborders_pre($order_id, $cart, $auth, $action, $issu | |
$suborder_cart['select_office'] = [$suborder_cart['select_office'][$key_group]]; | |
} | |
+ | |
+/** | |
+ * The "order_fulfillment_set_marketplace_shipping_to_product_group" hook handler. | |
+ * | |
+ * Actions performed: | |
+ * - Adds selected office data to all product groups which are using marketplace shipping | |
+ * | |
+ * @param array<string> $cart Cart data | |
+ * @param int $group_key Group key | |
+ * @param int $marketplace_group_key Marketplace group key | |
+ * @param array<string> $chosen_shipping_data Chosen shipping method data | |
+ * | |
+ * @see \onPrePlaceOrder() | |
+ * | |
+ * @return void | |
+ */ | |
+function fn_rus_sdek_order_fulfillment_set_marketplace_shipping_to_product_group(array &$cart, $group_key, $marketplace_group_key, array $chosen_shipping_data) | |
+{ | |
+ if (empty($cart['select_office'][$marketplace_group_key])) { | |
+ return; | |
+ } | |
+ $marketplace_group_selected_office_data = $cart['select_office'][$marketplace_group_key][$chosen_shipping_data['shipping_id']]; | |
+ $cart['select_office'][$group_key][$chosen_shipping_data['shipping_id']] = $marketplace_group_selected_office_data; | |
+} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app/addons/rus_sdek/init.php b/app/addons/rus_sdek/init.php | |
index 1f7f69a4f3..6e78a03648 100644 | |
--- a/app/addons/rus_sdek/init.php | |
+++ b/app/addons/rus_sdek/init.php | |
@@ -21,5 +21,6 @@ fn_register_hooks( | |
'get_cities_post', | |
'update_city_post', | |
'pickup_point_variable_init', | |
- 'place_suborders_pre' | |
+ 'place_suborders_pre', | |
+ 'order_fulfillment_set_marketplace_shipping_to_product_group' | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment