Bicss Posted December 30, 2015 Share Posted December 30, 2015 (edited) Hi, I have two products with differents shipping methods. 1. Carrier A, and pick up at store 2. Carrier B, and pick up at store. It only appears pick up at the store as shipping method because the two products have the same type of shipping. But if 1.Carrier A and pick up 2. Carrier B. It appears Carrier B + pickup at the store as shipping method. How can i make in the first example, to show all the combinations at the shipping method? Carrier A + B or, Carrier B + pick up at the store, or Carrier B + pick up at the store? thanks Edited December 30, 2015 by Bicss (see edit history) Link to comment Share on other sites More sharing options...
NemoPS Posted December 30, 2015 Share Posted December 30, 2015 I tried doing this for a client a few months ago, and it's been a nightmare. There is basically no way to do it, unless you rewrite the whole shipping system (if you mean to apply the same I had to) Link to comment Share on other sites More sharing options...
Bicss Posted December 30, 2015 Author Share Posted December 30, 2015 I dont see reason for Prestashop to do this. If you want to select other shipping method because, for example, the other is faster, why only appears the common shipping method? What solution did you? Thanks! Link to comment Share on other sites More sharing options...
NemoPS Posted December 30, 2015 Share Posted December 30, 2015 It used to work differently, but then they introduced some logic to group carriers in the smallest possible number. I am afraid it's way too complicated to explain, it took like 2 months and results were a bit buggy anyway. If you really want it, start by having a look at getAvailableCarrierList in the Carrier class Link to comment Share on other sites More sharing options...
Bicss Posted December 30, 2015 Author Share Posted December 30, 2015 Thanks a lot Nemo1! I will see this Link to comment Share on other sites More sharing options...
Bicss Posted December 30, 2015 Author Share Posted December 30, 2015 (edited) After trying some options: Changing on classes/cart.php Erasing the "break" at the end, appears multiple combinations on shipping method but 2shipping method combining with the third, not one shipping method combining with second one. Any idea why? Thanks // Step 4 : merge product from grouped_by_carriers into $package to minimize the number of package foreach ($grouped_by_carriers as $id_address_delivery => $products_in_stock_list) { if (!isset($package_list[$id_address_delivery])) $package_list[$id_address_delivery] = array( 'in_stock' => array(), 'out_of_stock' => array(), ); foreach ($products_in_stock_list as $key => $warehouse_list) { if (!isset($package_list[$id_address_delivery][$key])) $package_list[$id_address_delivery][$key] = array(); // Count occurance of each carriers to minimize the number of packages $carrier_count = array(); foreach ($warehouse_list as $id_warehouse => $products_grouped_by_carriers) { foreach ($products_grouped_by_carriers as $data) { foreach ($data['carrier_list'] as $id_carrier) { if (!isset($carrier_count[$id_carrier])) $carrier_count[$id_carrier] = 0; $carrier_count[$id_carrier]++; } } } arsort($carrier_count); foreach ($warehouse_list as $id_warehouse => $products_grouped_by_carriers) { if (!isset($package_list[$id_address_delivery][$key][$id_warehouse])) $package_list[$id_address_delivery][$key][$id_warehouse] = array(); foreach ($products_grouped_by_carriers as $data) { foreach ($carrier_count as $id_carrier => $rate) { if (in_array($id_carrier, $data['carrier_list'])) { if (!isset($package_list[$id_address_delivery][$key][$id_warehouse][$id_carrier])) $package_list[$id_address_delivery][$key][$id_warehouse][$id_carrier] = array( 'carrier_list' => $data['carrier_list'], 'warehouse_list' => $data['warehouse_list'], 'product_list' => array(), ); $package_list[$id_address_delivery][$key][$id_warehouse][$id_carrier]['carrier_list'] = array_intersect($package_list[$id_address_delivery][$key][$id_warehouse][$id_carrier]['carrier_list'], $data['carrier_list']); $package_list[$id_address_delivery][$key][$id_warehouse][$id_carrier]['product_list'] = array_merge($package_list[$id_address_delivery][$key][$id_warehouse][$id_carrier]['product_list'], $data['product_list']); break; } } } } } } Edited December 30, 2015 by Bicss (see edit history) Link to comment Share on other sites More sharing options...
Bicss Posted December 30, 2015 Author Share Posted December 30, 2015 If i change array_intersect($package_list[$id_address_delivery][$key][$id_warehouse][$id_carrier]['carrier_list'], $data['carrier_list']); fo array_merge($package_list[$id_address_delivery][$key][$id_warehouse][$id_carrier]['carrier_list'], $data['carrier_list']); Appears all the carriers but not combined Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now