Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Free Shipping Per Product for v2.3


GetSirius

Recommended Posts

I am having a problem with free shipping per product for osCommerce Online Merchant v2.3. If the weight of a product is not an even number, no decimals, the free shipping can fail and charge the customer for shipping. I installed the module a few months back and when orders started for the season some people were being charged shipping when they should not. This would only happen with certain number of products in the shopping cart. 1 or 2 and shipping was free, 3 sometimes, and most orders of 4 or more were getting charged. I had shipping weights of 1.2 and 1.5 pounds on these products. 

 

The fix I found was to change all product weights to 1 pound. That works, but I would like to use fractional pounds, some of my products only weigh an ounce. I need to use a weight to be able to charge shipping for export orders. I did not try weights other than 1 pound.

 

The problem seems to be that Free Shipping Per Product for osCommerce Online Merchant v2.3 does not like to have fractional weights. If anyone can help with this I would sure appreciate it.

 

 - Chuck

Link to comment
Share on other sites

  • 3 months later...

I'm in need of a program like this.  I'm running OSC234 and BS 3.3.7. 

 

I have attempted to install the latest version, but getting a few errows.  Also test run on check out and the items sellected for free shipping is not coming up on checkout as free.  Even if they are the only item's it still comes up with shipping options and haveing the customer pick one.  Also getting  (in BS boxes) the headings and pricing is not coming in and view the product is showing up twice (2 boxs). 

 

This is a great program if it could work.  I'm not a programer and have enough understading to how to fix or make it compatable with bootstrap. 

 

Like Chuck above, if someone can pickup this program and update it for 2.3.4 and BS it sure would be appreciated. 

Link to comment
Share on other sites

I have been working on this contribution because I really would like it to work.  If I was a programer I probability would understand how to fix it.  So I have gotten it to work except in 2 areas.  I have been keeping up with the changes and updating the install for this.  If I can gt help on fixing my other 2 problems I will be glad to share it.  Like I mentioned above I'm running OSC234 and BS 3.3.7.

 

1st problem.  After selecting an item to buy, click on what is in the shopping cart [items button] and I have double boxes and images.  I do not know what file is doing this.  I know it came from one of the files modified that is listed in the add on.  Includes/classes/shopping_cart.php doesn't seem to be it.    What file is shopping cart linked to?  What do I need to look for?

 

2nd problem.  When checking out, it still wants to charge shipping on items marked for "free shipping".  Free shipping if dollar amount is still working.  What do I need to do to fix this?

Link to comment
Share on other sites

Found and fixed my shopping problem.  The install.txt was way off to get to work with BS. 

 

That just leaves the check out shipping not showing free shipping for an item's.  This one I have no idea how to fix.  Reaching out for help.

Link to comment
Share on other sites

@@dculley

 

Hi (again) :D

 

I just quickly installed the free shipping per product addon. Works fine for me so far. I must admit I didn't test it thorough yet.

I installed this addon into a fresh 2.3.4 BS GOLD shop.

Added a new product with free shipping, products price $10.

Activated the ot_shipping module and set

 

Display Shipping
true

Sort Order
2

Allow Free Shipping by Order Total
true

Free Shipping For Orders Over
$50.00

Allow Free Shipping by Product
true

Provide Free Shipping For Orders Made
both

 

added only the free shipping product to the cart and it shows me this text.

 

Free Shipping

Free shipping for all of your cart products

 

If I add 6x that new item I get this message.

 

Free Shipping

Free shipping for orders over $50.00

 

So it seems to do what it suppose to do. Nevertheless that addon needs a lot of code cleaning and adjusting to make it work nicely with osC BS GOLD but it is not impossible.

 

Here is my checkout_shipping.php if you want to compare it with yours. (That file is stock osC no design changes applied only that addon.)

<?php
/*
  $Id$

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2014 osCommerce

  Released under the GNU General Public License
*/

  require('includes/application_top.php');
  require('includes/classes/http_client.php');

// if the customer is not logged on, redirect them to the login page
  if (!tep_session_is_registered('customer_id')) {
    $navigation->set_snapshot();
    tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
  }

// if there is nothing in the customers cart, redirect them to the shopping cart page
  if ($cart->count_contents() < 1) {
    tep_redirect(tep_href_link(FILENAME_SHOPPING_CART));
  }

// if no shipping destination address was selected, use the customers own address as default
  if (!tep_session_is_registered('sendto')) {
    tep_session_register('sendto');
    $sendto = $customer_default_address_id;
  } else {
// verify the selected shipping address
    if ( (is_array($sendto) && empty($sendto)) || is_numeric($sendto) ) {
      $check_address_query = tep_db_query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customer_id . "' and address_book_id = '" . (int)$sendto . "'");
      $check_address = tep_db_fetch_array($check_address_query);

      if ($check_address['total'] != '1') {
        $sendto = $customer_default_address_id;
        if (tep_session_is_registered('shipping')) tep_session_unregister('shipping');
      }
    }
  }

  require(DIR_WS_CLASSES . 'order.php');
  $order = new order;

// register a random ID in the session to check throughout the checkout procedure
// against alterations in the shopping cart contents
  if (!tep_session_is_registered('cartID')) {
    tep_session_register('cartID');
  } elseif (($cartID != $cart->cartID) && tep_session_is_registered('shipping')) {
    tep_session_unregister('shipping');
  }

  $cartID = $cart->cartID = $cart->generate_cart_id();

// if the order contains only virtual products, forward the customer to the billing page as
// a shipping address is not needed
  if ($order->content_type == 'virtual') {
    if (!tep_session_is_registered('shipping')) tep_session_register('shipping');
    $shipping = false;
    $sendto = false;
    tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
  }

  $total_weight = $cart->show_weight();
  $total_count = $cart->count_contents();

// PRODUCTS SHIP FREE START
// get free shipping before calculating cart weight and count
// load all enabled shipping modules - moved below
/*
  require(DIR_WS_CLASSES . 'shipping.php');
  $shipping_modules = new shipping;
*/

$free_shipping = false;
$products_ship_free = false;
$free_pass = false;
$ship_free_count = 0;
if ((defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING') && MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') || (defined('MODULE_ORDER_TOTAL_PRODUCTS_SHIP_FREE') && MODULE_ORDER_TOTAL_PRODUCTS_SHIP_FREE == 'true'))
	{
	switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION)
		{
		case 'national': if ($order->delivery['country_id'] == STORE_COUNTRY) $free_pass = true;
		break;
		case 'international': if ($order->delivery['country_id'] != STORE_COUNTRY) $free_pass = true;
		break;
		case 'both': $free_pass = true;
		break;
		}
	if($free_pass == true)
		{
		if (defined('MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING') && MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true' && $order->info['total'] >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER)
			$free_shipping = true;
		elseif ( defined('MODULE_ORDER_TOTAL_PRODUCTS_SHIP_FREE') && (MODULE_ORDER_TOTAL_PRODUCTS_SHIP_FREE == 'true'))	
			{
			$products = $cart->get_products();
			for ($i=0, $n=sizeof($products); $i<$n; $i++)
				{
				if ($products[$i]['ship_free'] == '1')
					{
					$ship_free_count += $products[$i]['quantity'];
					$total_weight -= $products[$i]['weight']*$products[$i]['quantity'];
					$total_count -= $products[$i]['quantity'];
					}
				}
			if ($total_weight == 0 && $total_count == 0)
				{
				$products_ship_free = true;
				$free_shipping = true;
				}
			}
		if ($free_shipping == true || $products_ship_free == true || $ship_free_count > 0)
			include(DIR_WS_LANGUAGES . $language . '/modules/order_total/ot_shipping.php');
		}
	}

// load all enabled shipping modules
  require(DIR_WS_CLASSES . 'shipping.php');
  $shipping_modules = new shipping;

// PRODUCTS SHIP FREE END

// process the selected shipping method
  if ( isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process') && isset($HTTP_POST_VARS['formid']) && ($HTTP_POST_VARS['formid'] == $sessiontoken) ) {
    if (!tep_session_is_registered('comments')) tep_session_register('comments');
    if (tep_not_null($HTTP_POST_VARS['comments'])) {
      $comments = tep_db_prepare_input($HTTP_POST_VARS['comments']);
    }

    if (!tep_session_is_registered('shipping')) tep_session_register('shipping');

    if ( (tep_count_shipping_modules() > 0) || ($free_shipping == true) ) {
      if ( (isset($HTTP_POST_VARS['shipping'])) && (strpos($HTTP_POST_VARS['shipping'], '_')) ) {
        $shipping = $HTTP_POST_VARS['shipping'];

        list($module, $method) = explode('_', $shipping);
        if ( is_object($$module) || ($shipping == 'free_free') ) {
          if ($shipping == 'free_free') {
            $quote[0]['methods'][0]['title'] = FREE_SHIPPING_TITLE;
            $quote[0]['methods'][0]['cost'] = '0';
          } else {
            $quote = $shipping_modules->quote($method, $module);
          }
          if (isset($quote['error'])) {
            tep_session_unregister('shipping');
          } else {
            if ( (isset($quote[0]['methods'][0]['title'])) && (isset($quote[0]['methods'][0]['cost'])) ) {
              $shipping = array('id' => $shipping,
                                'title' => (($free_shipping == true) ?  $quote[0]['methods'][0]['title'] : $quote[0]['module'] . ' (' . $quote[0]['methods'][0]['title'] . ')'),
                                'cost' => $quote[0]['methods'][0]['cost']);

              tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
            }
          }
        } else {
          tep_session_unregister('shipping');
        }
      }
    } else {
      if ( defined('SHIPPING_ALLOW_UNDEFINED_ZONES') && (SHIPPING_ALLOW_UNDEFINED_ZONES == 'False') ) {
        tep_session_unregister('shipping');
      } else {
        $shipping = false;
        tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
      }
    }
  }

// get all available shipping quotes
  $quotes = $shipping_modules->quote();

// if no shipping method has been selected, automatically select the cheapest method.
// if the modules status was changed when none were available, to save on implementing
// a javascript force-selection method, also automatically select the cheapest shipping
// method if more than one module is now enabled
  if ( !tep_session_is_registered('shipping') || ( tep_session_is_registered('shipping') && ($shipping == false) && (tep_count_shipping_modules() > 1) ) ) $shipping = $shipping_modules->cheapest();

  require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CHECKOUT_SHIPPING);

  if ( defined('SHIPPING_ALLOW_UNDEFINED_ZONES') && (SHIPPING_ALLOW_UNDEFINED_ZONES == 'False') && !    tep_session_is_registered('shipping') && ($shipping == false) ) {
  $messageStack->add_session('checkout_address', ERROR_NO_SHIPPING_AVAILABLE_TO_SHIPPING_ADDRESS);
  tep_redirect(tep_href_link(FILENAME_CHECKOUT_SHIPPING_ADDRESS, '', 'SSL'));
}

  $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
  $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));

  require(DIR_WS_INCLUDES . 'template_top.php');
?>

<div class="page-header">
  <h1><?php echo HEADING_TITLE; ?></h1>
</div>

<?php echo tep_draw_form('checkout_address', tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'), 'post', 'class="form-horizontal"', true) . tep_draw_hidden_field('action', 'process'); ?>

<div class="contentContainer">
  <h2><?php echo TABLE_HEADING_SHIPPING_ADDRESS; ?></h2>

  <div class="contentText row">
    <div class="col-sm-8">
      <div class="alert alert-warning">
        <?php echo TEXT_CHOOSE_SHIPPING_DESTINATION; ?>
        <div class="clearfix"></div>
        <div class="pull-right">
          <?php echo tep_draw_button(IMAGE_BUTTON_CHANGE_ADDRESS, 'glyphicon glyphicon-home', tep_href_link(FILENAME_CHECKOUT_SHIPPING_ADDRESS, '', 'SSL')); ?>
        </div>
        <div class="clearfix"></div>
      </div>
    </div>
    <div class="col-sm-4">
      <div class="panel panel-primary">
        <div class="panel-heading"><?php echo TITLE_SHIPPING_ADDRESS; ?></div>
        <div class="panel-body">
          <?php echo tep_address_label($customer_id, $sendto, true, ' ', '<br />'); ?>
        </div>
      </div>
    </div>
  </div>

  <div class="clearfix"></div>

<?php
  if (tep_count_shipping_modules() > 0) {
?>

  <h2><?php echo TABLE_HEADING_SHIPPING_METHOD; ?></h2>

<?php
    if (sizeof($quotes) > 1 && sizeof($quotes[0]) > 1) {
?>

  <div class="contentText">
    <div class="alert alert-warning">
      <div class="row">
        <div class="col-xs-8">
		
			<!-- PRODUCTS SHIP FREE START -->
				<?php 
				if ($ship_free_count > 0 && $products_ship_free != true) {
					echo sprintf(PRODUCTS_SHIP_FREE_COUNT, $ship_free_count);
				} else { 
					echo TEXT_CHOOSE_SHIPPING_METHOD;
				} 
				?>
			<!-- PRODUCTS SHIP FREE END -->
		
        </div>
        <div class="col-xs-4 text-right">
          <?php echo '<strong>' . TITLE_PLEASE_SELECT . '</strong>'; ?>
        </div>
      </div>
    </div>
  </div>

<?php
    } elseif ($free_shipping == false) {
?>

  <div class="contentText">
    <div class="alert alert-info"><?php echo TEXT_ENTER_SHIPPING_INFORMATION; ?></div>
  </div>


<?php
    } elseif ($free_shipping == false) {
?>

  <div class="contentText">
  
	<!-- PRODUCTS SHIP FREE START -->
		<?php 
		if ($ship_free_count > 0 && $products_ship_free != true) {
			echo '<div class="alert alert-info">' . sprintf(PRODUCTS_SHIP_FREE_COUNT_ONLY, $ship_free_count) . '</div>';
		} else { 
			echo '<div class="alert alert-info">' . TEXT_ENTER_SHIPPING_INFORMATION . '</div>';
		} 
		?>
	<!-- PRODUCTS SHIP FREE END -->
	
  </div>

<?php
    }
?>

  <div class="contentText">
    <table class="table table-striped table-condensed table-hover">
      <tbody>

<?php
    if ($free_shipping == true) {
?>

    <div class="contentText">
      <div class="panel panel-success">
        <div class="panel-heading"><strong><?php echo FREE_SHIPPING_TITLE; ?></strong> <?php echo $quotes[$i]['icon']; ?></div>
        <div class="panel-body">
		
			<!-- PRODUCTS SHIP FREE START -->
				<?php
				if ($products_ship_free == true) {
					echo PRODUCTS_SHIP_FREE_DESCRIPTION . tep_draw_hidden_field('shipping', 'free_free');
				} else {
					echo sprintf(FREE_SHIPPING_DESCRIPTION, $currencies->format(MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER)) . tep_draw_hidden_field('shipping', 'free_free');
				}
				?>
			<!-- PRODUCTS SHIP FREE END -->
		
        </div>
      </div>
    </div>

<?php
    } else {
      for ($i=0, $n=sizeof($quotes); $i<$n; $i++) {
        for ($j=0, $n2=sizeof($quotes[$i]['methods']); $j<$n2; $j++) {
// set the radio button to be checked if it is the method chosen
          $checked = (($quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'] == $shipping['id']) ? true : false);

          echo '      <tr>' . "\n";

?>

        <td>
          <strong><?php echo $quotes[$i]['module']; ?></strong>
          <?php
          if (isset($quotes[$i]['icon']) && tep_not_null($quotes[$i]['icon'])) echo ' ' . $quotes[$i]['icon'];
          ?>

          <?php
          if (isset($quotes[$i]['error'])) {
            echo '<div class="help-block">' . $quotes[$i]['error'] . '</div>';
          }
          ?>

          <?php
          if (tep_not_null($quotes[$i]['methods'][$j]['title'])) echo '<div class="help-block">' . $quotes[$i]['methods'][$j]['title'] . '</div>';
          ?>
          </td>

<?php
            if ( ($n > 1) || ($n2 > 1) ) {
?>

        <td align="right">
          <?php
          if (isset($quotes[$i]['error'])) {
            // nothing
            echo ' ';
          }
          else {
            echo $currencies->format(tep_add_tax($quotes[$i]['methods'][$j]['cost'], (isset($quotes[$i]['tax']) ? $quotes[$i]['tax'] : 0))); ?>  <?php echo tep_draw_radio_field('shipping', $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'], $checked, 'required aria-required="true"');
          }
          ?>
        </td>

<?php
            } else {
?>

        <td align="right"><?php echo $currencies->format(tep_add_tax($quotes[$i]['methods'][$j]['cost'], (isset($quotes[$i]['tax']) ? $quotes[$i]['tax'] : 0))) . tep_draw_hidden_field('shipping', $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id']); ?></td>

<?php
            }
?>

      </tr>

<?php
        }
      }
    }
?>

      </tbody>
    </table>
  </div>

<?php
  }
?>

  <hr>

  <div class="contentText">
    <div class="form-group">
      <label for="inputComments" class="control-label col-xs-4"><?php echo TABLE_HEADING_COMMENTS; ?></label>
      <div class="col-xs-8">
        <?php
        echo tep_draw_textarea_field('comments', 'soft', 60, 5, $comments, 'id="inputComments" placeholder="' . TABLE_HEADING_COMMENTS . '"');
        ?>
      </div>
    </div>
  </div>

  <div class="buttonSet">
    <div class="text-right"><?php echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'glyphicon glyphicon-chevron-right', null, 'primary'); ?></div>
  </div>

  <div class="clearfix"></div>

  <div class="contentText">
    <div class="stepwizard">
      <div class="stepwizard-row">
        <div class="stepwizard-step">
          <button type="button" class="btn btn-primary btn-circle">1</button>
          <p><?php echo CHECKOUT_BAR_DELIVERY; ?></p>
        </div>
        <div class="stepwizard-step">
          <button type="button" class="btn btn-default btn-circle" disabled="disabled">2</button>
          <p><?php echo CHECKOUT_BAR_PAYMENT; ?></p>
        </div>
        <div class="stepwizard-step">
          <button type="button" class="btn btn-default btn-circle" disabled="disabled">3</button>
          <p><?php echo CHECKOUT_BAR_CONFIRMATION; ?></p>
        </div>
      </div>
    </div>
  </div>

</div>

</form>

<?php
  require(DIR_WS_INCLUDES . 'template_bottom.php');
  require(DIR_WS_INCLUDES . 'application_bottom.php');
?>

Edited by Tsimi
Link to comment
Share on other sites

I couldn't leave it and rewrote the install manual so that it can be used with osC 2.3.4 BS GOLD

I have not really improved it just fixed some layout issues. I don't know if this addon might conflict with shipping modules and what not. I guess it should work as it did previous.

There is still plenty of room for improvement so please don't hesitate to add them or post them here.

 

Here the new install manual:

 

 

 

Link to comment
Share on other sites

Hi Lambros @@Tsimi

 

I went by your install instructions, (very good instructions I may say), All most all is working great.  I like the color added and the line up.  Looks a lot better.  The only area that it is not still working is in the Shipping Method section of checkout.  With just the item checked as free shipping and nothing else.  You go to check out and USPS comes up for customer to pick method of shipping, but nothing else.  Missing the "your item ships for free".  I set the Free by price to $25 and selected a few more items.  Go to check out and under the shipping method it is working great. It only shows that you order ships fee, no USPS pricing. 

 

Now if we can only get the free by product to show and work, we will have a home run.

 

Is there a file I can send?  If so please tell me and also how to add it the post. Like you did above.  Or file.

 

Thanks for all your help. :thumbsup:

Link to comment
Share on other sites

@@Tsimi

 

I forgot to mintion, my checkout_shipping.php matches yours.

hmm...if that is the case...have you tried a different shipping module? like per item or flat rate? does it work there?

Link to comment
Share on other sites

Can you take a look at the products table inside the database and confirm that there is a product that has free shipping flagged as true?

Edited by Tsimi
Link to comment
Share on other sites

  • 5 weeks later...

I am utilizing this contribution on OSC 2.3.3.4 and on the checkout_confirmation.php it shows: United Parcel Service (1 pkg, 0 lbs total) (UPS Ground (billed dimensional weight 1 LBS)): $11.69 rather than Free Shipping $0.00

Link to comment
Share on other sites

  • 1 year later...

I couldn't leave it and rewrote the install manual so that it can be used with osC 2.3.4 BS GOLD

I have not really improved it just fixed some layout issues. I don't know if this addon might conflict with shipping modules and what not. I guess it should work as it did previous.

There is still plenty of room for improvement so please don't hesitate to add them or post them here.

 

Here the new install manual:

 

attachicon.gifFSPP_install_oscBS.zip

@@Tsimi can you plz repost the the addon!

 

Joe 

Link to comment
Share on other sites

@@joe122joe

 

Hi Joe

 

Sorry to disappoint you but I don't have that file anymore.

I checked through my PCs, USB sticks and external hard discs but no luck.

I had a PC problem last year and needed to setup everything from scratch I most likely lost the data there.

Link to comment
Share on other sites

@@joe122joe

 

Hi Joe

 

Download the addon here

 

http://addons.oscommerce.com/info/8409

 

and use this following manual to install it into the osC BS Edge version.

 

install_osC_BS_Edge.txt

 

I did not improve the addon at all I just simply updated the install manual and that's it.

Edited by Tsimi
Link to comment
Share on other sites

@@joe122joe

 

You're welcome.

I was sick at home so I thought I recreate that lost manual.

I think I did a better job on my first, lost manual but this one should suffice, I hope.

You can change bits and pieces of the code to get a better visual result.

Instead of the simple text (Ships free) you can use your imagination and maybe add an icon or image instead.

Or move the text to a different position.

 

Enjoy!

Edited by Tsimi
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...