Jump to content

Free shipping for selected categories or products


KORG

Recommended Posts

Hi
I to would like to know how to do this, i have one product i would like to offer free delivery on as a special offer but it seems impossible to do.
I have searched the forum and others seem to have the same problem and no one has a clear answer if it is possible.

Someone must know if it can be done.
thanks

Link to comment
Share on other sites

The only way this can be done at the moment is to go to Payment > Vouchers and create a voucher applicable only to the categories you want free shipping for that all customers can use. To make individual products free shipping, you would have to create a "Free Shipping" category and put all the products you want as free shipping in it. Unfortunately, this means you would need to enter the voucher code in the description of each of the products and the customer would have to enter it manually when checking out to get the discount. You would need to modify code to have the voucher automatically applied to the cart when the product is added.

Link to comment
Share on other sites

  • 11 months later...
  • 2 weeks later...

put this code

$categories =  array( //add id of free shipping categories here 
                   array('id_category'=>10128), 
                   array('id_category'=>10125)
               );
if (self::$_productIds[$id_product] == FALSE)
{
   self::$_productIds[$id_product] = Product::idIsOnCategoryId($id_product, $categories);
}



before

return self::$_productIds[$id_product];


in function getIdFromIdProduct at classes/ProductDownload.php

this will make prestashop think products that are in selected categories are virtual products (work with version 1.25).
virtual product = free shipping

then edit classes/OrderHistory.php

change :

           if ($virtualProducts = $order->getVirtualProducts() AND $this->id_order_state==_PS_OS_PAYMENT_)
           {
               global $smarty;
               $display = '';
               $assign = array();
               foreach ($virtualProducts AS $key => $virtualProduct)
               {
                   $id_product_download = ProductDownload::getIdFromIdProduct($virtualProduct['product_id']);
                   $product_download = new ProductDownload($id_product_download);
                   $assign[$key]['name'] = $product_download->display_filename;
                   $assign[$key]['link'] = $product_download->getTextLink(false, $virtualProduct['download_hash']);
                   if ($virtualProduct['download_deadline'] != '0000-00-00 00:00:00')
                       $assign[$key]['deadline'] = Tools::displayDate($virtualProduct['download_deadline'], $order->id_lang);
                   if ($product_download->nb_downloadable != 0)
                       $assign[$key]['downloadable'] = $product_download->nb_downloadable;
               }
               $smarty->assign('virtualProducts', $assign);
               $iso = Language::getIsoById(intval($order->id_lang));
               $links = $smarty->fetch(_PS_MAIL_DIR_.$iso.'/download-product.tpl');
               $tmpArray = array('{nbProducts}' => count($virtualProducts), '{virtualProducts}' => $links);
               $data = array_merge ($data, $tmpArray);
               global $_LANGMAIL;
               $subject = 'Virtual product to download';
               Mail::Send(intval($order->id_lang), 'download_product', ((is_array($_LANGMAIL) AND key_exists($subject, $_LANGMAIL)) ? $_LANGMAIL[$subject] : $subject), $data, $result['email'], $result['firstname'].' '.$result['lastname']);
           }



with:

           if ($virtualProducts = $order->getVirtualProducts() AND $this->id_order_state==_PS_OS_PAYMENT_)
           {
               global $smarty;
               $display = '';
               $assign = array();
               foreach ($virtualProducts AS $key => $virtualProduct)
               {
                   $id_product_download = ProductDownload::getIdFromIdProduct($virtualProduct['product_id']);
                   $product_download = new ProductDownload($id_product_download);
                   if ($product_download->display_filename == NULL)
                   {
                       continue;
                   }
                   $assign[$key]['name'] = $product_download->display_filename;
                   $assign[$key]['link'] = $product_download->getTextLink(false, $virtualProduct['download_hash']);
                   if ($virtualProduct['download_deadline'] != '0000-00-00 00:00:00')
                       $assign[$key]['deadline'] = Tools::displayDate($virtualProduct['download_deadline'], $order->id_lang);
                   if ($product_download->nb_downloadable != 0)
                       $assign[$key]['downloadable'] = $product_download->nb_downloadable;
               }
               $smarty->assign('virtualProducts', $assign);
               $iso = Language::getIsoById(intval($order->id_lang));
               $links = $smarty->fetch(_PS_MAIL_DIR_.$iso.'/download-product.tpl');
               $tmpArray = array('{nbProducts}' => count($virtualProducts), '{virtualProducts}' => $links);
               $data = array_merge ($data, $tmpArray);
               global $_LANGMAIL;
               $subject = 'Virtual product to download';
               if(count($assign) > 0)
               {
                   Mail::Send(intval($order->id_lang), 'download_product', ((is_array($_LANGMAIL) AND key_exists($subject, $_LANGMAIL)) ? $_LANGMAIL[$subject] : $subject), $data, $result['email'], $result['firstname'].' '.$result['lastname']);
               }
           }



this use for avoid prestashop send email with blank links.

sorry for my bad english.

Link to comment
Share on other sites

  • 8 months later...
  • 4 months later...
I think the easest way would be to set up a group called, let say "free shipping" and create a simple if/else statement to skip shipping charges.

Unfortunately this won't work to people registering the moment they buy the very first time.

Consider a customer buying a product during the night. He registers to your site, then, reading the claim "free shipping for this category", makes a buy.

Nobody put him on the "free shipping" group then he cannot get the discount, then he, probably, would not make the buy anymore.

The solution must be elsewhere.

Link to comment
Share on other sites

If that code that seskan posted doesn't do the trick or if you'd rather set up the voucher you could set it to display the voucher code on the first step of the checkout process directly above the voucher code box. So it's only mildly inconvenient for customers since it's right there in their faces. If they still don't enter the code then they don't deserve the free shipping anyway. :D

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...