Post by isotel » Wed Jan 21, 2015 7:41 am

I feel like this is an easy answer, but for some reason im flabergasted as to how to make this work..

I have a store on 1.5.6.4 and i would like to have calculated shipping (USPS Priority) for most of my orders, but some orders i can just ship with traditional Mail (Stamp).. so id either like to build it into the price and offer free shipping, or just tack on the $0.49

so i only want certain items to have free shipping.. this seems like it should be easy.

Newbie

Posts

Joined
Wed Jul 25, 2012 4:50 am

Post by Johnathan » Wed Jan 21, 2015 11:02 pm

Build the shipping into their price, and make their weight 0, so they don't affect the USPS calculation. You can then use Restrict Shipping Methods to make USPS appear when the cart weight is at least 0.01, and Free Shipping appear when the cart weight is 0.

Image Image Image Image Image


User avatar
Administrator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by alexball » Fri Jul 22, 2016 8:36 pm

Hi,

I've used the options of single product to create a free shipping value, for me work.
Create an RADIO option called "shipping" (or so on) then add a value called "free". This is the option to free shipping for a single product. Well, add this option to all product that you want free shipping (Important: this option must be REQUIRED to work properly!).

Add some little change to the code of your shipping method, for example I use the flat method, so i've changed the model/shipping/flat.php file:

Add:

Code: Select all

$free_shipping = 0;	
		$total_products = count($this->cart->getProducts());
	
		foreach($this->cart->getProducts() as $product) {
			foreach($product['option'] as $option) {
				if($option['option_value'] == 'free') {
					$free_shipping++;
				}
			}
		}
		
		$shipping_cost = $this->config->get('flat_cost');
		if($free_shipping == $total_products) { /*If ALL products are free shipping set cost 0 else add shipping cost*/
			$shipping_cost = 0;
		}
Change:

Code: Select all

$quote_data['flat'] = array(
        		'code'         => 'flat.flat',
        		'title'        => $this->language->get('text_title'),
        		'cost'         => $shipping_cost,
        		'tax_class_id' => $this->config->get('flat_tax_class_id'),
				'text'         => $this->currency->format($this->tax->calculate($shipping_cost, $this->config->get('flat_tax_class_id'), $this->config->get('config_tax')))
			);
If you want you can change product.tpl to show an image of free shipping like this:

Code: Select all

<?php if ($option['type'] == 'radio') { ?>
        <div id="option-<?php echo $option['product_option_id']; ?>" class="option">
          <!-- Free shipping - Start -->
          <?php if ($option['name'] == 'shipping') { ?>
          		<?php foreach ($option['option_value'] as $option_value) { ?>
                	<?php if($option_value['name'] == 'free') { ?>
                    	<img src="MY FREE SHIPPING IMAGE URL" alt="Free Shipping" />
              			<input type="radio" name="option[<?php echo $option['product_option_id']; ?>]" value="<?php echo $option_value['product_option_value_id']; ?>" id="option-value-<?php echo $option_value['product_option_value_id']; ?>" checked style="display: none;" />
                    <?php } ?>
          	  	<?php } ?>
          <?php } else { ?>
          <!-- Free shipping - End --> 
              <?php if ($option['required']) { ?>
              <span class="required">*</span>
              <?php } ?>
              <b><?php echo $option['name']; ?>:</b><br />
              <?php foreach ($option['option_value'] as $option_value) { ?>
              <input type="radio" name="option[<?php echo $option['product_option_id']; ?>]" value="<?php echo $option_value['product_option_value_id']; ?>" id="option-value-<?php echo $option_value['product_option_value_id']; ?>" />
              <label for="option-value-<?php echo $option_value['product_option_value_id']; ?>"><?php echo $option_value['name']; ?>
                <?php if ($option_value['price']) { ?>
                (<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)
                <?php } ?>
              </label>
              <br />
          	  <?php } ?>
          <?php } ?><!-- End else -->
        </div>
        <br />
        <?php } ?><!-- End radio Option -->
In same way you can change feature module or so on...
For now i've not find bug, please report a issue if you find.

Newbie

Posts

Joined
Fri Jul 22, 2016 8:20 pm
Who is online

Users browsing this forum: No registered users and 30 guests