brownd92 Posted October 7, 2014 Share Posted October 7, 2014 Hi there, I have a major problem. I have free shipping enabled on my store which starts at £150. this is fine in most cases. However I have products which require refrigerated delivery at an aditional cost of £10. This is setup in shipping of the product as an aditional cost. However whenever an order goes past the free shipping amount this cost dissapears. There is only one charge per order even if there are several refregerated items in the order. Esentially im looking to add a shipping cost of £10 to the order if there are one or more items in the basket which have a feature associated with it which is "refrigerated=yes" regardless of the free shipping amount. Any ideas? Link to comment Share on other sites More sharing options...
PascalVG Posted October 10, 2014 Share Posted October 10, 2014 Esentially im looking to add a shipping cost of £10 to the order if there are one or more items in the basket which have a feature associated with it which is "refrigerated=yes" regardless of the free shipping amount. Hi Brown, I think I have an Idea: Very similar to another topic Where someone asked some extra costs per Category, www.prestashop.com/forums/topic/255147-per-category-shipping-cost/#entry1817410 I modified this code to make sure even when free shipping is reached, these fixed (in this case feature dependent) price is added. N.B., I didn't bother to make the added price product dependent, as you mentioned "one or more" products. I just added a field to the shipping preferences where you can add a price, which will be added if a product in the cart has a feature with feature value as set in the code. N.B. 2: I didn't bother to make a module or so out of it (yet?), just made it so that you can go on with your project. This means the feature ID code and feature value ID code must be hard coded in the code I provide below. I will lead you through the process: (Sample code form PS 1.6.0.8) Edit the file: controllers/admin/AdminShippingController.php (Make backup!!!, or even better, make an override of the controller. See developers guide how to do this, or search the forum...) - http://doc.prestasho...dingacontroller - http://doc.prestasho...dingacontroller In this file, go to the function __construct(): Here you will find the code below: ... 'fields' => array( 'PS_SHIPPING_HANDLING' => array( 'title' => $this->l('Handling charges'), 'suffix' => $this->context->currency->getSign().' '.$this->l('(tax excl.)'), 'cast' => 'floatval', 'type' => 'text', 'validation' => 'isPrice'), /* ADD THIS CODE, SHOWN BELOW*/ 'PS_SHIPPING_HANDLING_FOR_FEATURE' => array( 'title' => $this->l('Category specific handling charges'), 'suffix' => $this->context->currency->getSign().' '.$this->l('(tax excl.)'), 'cast' => 'floatval', 'type' => 'text', 'validation' => 'isPrice'), You see, I added a field "Category specific handling charges", which value will be stored in the ps_configuration table with the name 'PS_SHIPPING_HANDLING_FOR_FEATURE' save the file and go to the shipping->configuration screen, and you will see the field, where you can add a number, just like the general 'shipping charges'. To make it useful, we need to add these charges to the shipping costs. This function is defined in /classes/Cart.php. Again, make a backup!!!, or better, make an override: http://doc.prestasho...verridingaclass In this file, go to function: public function getPackageShippingCost($id_carrier = null, $use_tax = true, Country $default_country = null, $product_list = null, $id_zone = null) and go to the part where they add the fixed shipping charge (search for PS_SHIPPING_HANDLING) First get the value from ps_configuration: $configuration = Configuration::getMultiple(array( 'PS_SHIPPING_FREE_PRICE', 'PS_SHIPPING_HANDLING', 'PS_SHIPPING_HANDLING_FOR_FEATURE', // <-- add this line 'PS_SHIPPING_METHOD', 'PS_SHIPPING_FREE_WEIGHT' )); Directly below this code, Add the following code. (By putting this code here, it will be added BEFORE it is decided if the "free shipping price" (as defined in Shipping->preferences) is reached, and thus will be charged, even when the cart total has reached free shipping value.) // Adding Fixed charges, independent of 'free shipping' $FeatCostAdded = false; // We want to add category shipping costs only once $FeatShippingFeatures[] = 8; // ID of fixed feature to add costs for ('Refrigerated' in your case) $FeatShippingFeatureValues[] = 34; // ID of Value of above feature ('Yes' of Refrigerated feature in your case) foreach ($products as $product) { if (!$FeatCostAdded && isset($configuration['PS_SHIPPING_HANDLING_FOR_FEATURE'])) { $FeatCostAdded = (count(array_intersect(array_map(function($element){return $element['id_feature'];}, Product::getFeaturesStatic((int)$product['id_product'])), $FeatShippingFeatures)) > 0) ? true : false; if ($FeatCostAdded) { // we have found the feature, now check if value is correct $FeatCostAdded = (count(array_intersect(array_map(function($element){return $element['id_feature_value'];}, Product::getFeaturesStatic((int)$product['id_product'])), $FeatShippingFeatureValues)) > 0) ? true : false; if ($FeatCostAdded) { $shipping_cost += (float)$configuration['PS_SHIPPING_HANDLING_FOR_FEATURE']; // !!!Pas, Feature found, only add costs once } } } } // Free fees ... // rest of initial code To find the values you need to change in code line 3 and 4 (id_feature of 'refrigerated' feature, and id from refrigerated:'yes' feature-value: Feature ID do this: - go to Catalog->Product features menu. There you will see your 'Refrigerated' feature, with a number just in front of it. This is the ID of feature The id of your value of the feature is a then easy to find. just click on the 'refrigerated' feature and you will see its values (probably 'Yes' and 'No'. In front of the YES value you will see its ID Save the file and take a few products, one or more that has the refrigerated with value YES that you added in your shopping cart. then go to the cart summary and see if it works. Also try to see if free shipping is reached if ONLY these fixed, 'feature dependent', costs are added. If not reached, both fixed costs and shipping costs as defined in the shipping tables should be added. Hope this helps, let me know. pascal 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