Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Free Shipping Per Product for v2.3


GetSirius

Recommended Posts

On 4/19/2017 at 7:57 AM, Tsimi said:

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.

Tsimi

FIRST and foremost THANK YOU for the installation instructions for OSC Bootstrap.  They were RIGHT ON.  Have used this particular mod for years in an OSC 2.3.4 store and really did NOT want to change.  The old saying "IF it ain't broke  DON'T fix it" applies.

HOWEVER, there is one spot that does not exist in the BS Frozen version (All the rest matched up perfectly)

That instruction set is this code


***********************************************
catalog/product_info.php  NOT AVAIL 
***********************************************
Find:

<div class="page-header">
  <div class="row">  
    <h1 class="col-sm-8"><?php echo $products_name; ?></h1>
    <h2 class="col-sm-4 text-right-not-xs" itemprop="offers" itemscope itemtype="http://schema.org/Offer"><?php echo $products_price; ?></h2>
  </div>
</div>
	
Replace with:

<?php
// PRODUCTS SHIP FREE START
	if(tep_products_ship_free_check($product_info['products_id']))
	      $freeship_str .= '<br /><span class="smallText">(' . TEXT_PRODUCT_SHIPS_FREE . ')</span>';	
?>
<div class="page-header">
  <div class="row">  
    <h1 class="col-sm-8"><?php echo $products_name; ?></h1>
    <h2 class="col-sm-4 text-right-not-xs" itemprop="offers" itemscope itemtype="http://schema.org/Offer"><?php echo $products_price . $freeship_str; ?></h2>
  </div>
</div>
<!-- PRODUCTS SHIP FREE END //-->

The FROZEN version of the file reads like this

<?php
/*
  $Id$

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

  Copyright (c) 2010 osCommerce

  Released under the GNU General Public License
*/

  require('includes/application_top.php');

  if (!isset($_GET['products_id'])) {
    tep_redirect(tep_href_link('index.php'));
  }

  require('includes/languages/' . $language . '/product_info.php');

  $product_check_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$_GET['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
  $product_check = tep_db_fetch_array($product_check_query);

  require('includes/template_top.php');

  if ($product_check['total'] < 1) {
?>

<div class="contentContainer">

  <div class="row">
    <?php echo $oscTemplate->getContent('product_info_not_found'); ?>
  </div>
  
</div>

<?php
  } else {
    $product_info_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, p.products_model, p.products_quantity, p.products_image, pd.products_url, p.products_price, p.products_tax_class_id, p.products_date_added, p.products_date_available, p.manufacturers_id, p.products_gtin from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$_GET['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
    $product_info = tep_db_fetch_array($product_info_query);

    tep_db_query("update " . TABLE_PRODUCTS_DESCRIPTION . " set products_viewed = products_viewed+1 where products_id = '" . (int)$_GET['products_id'] . "' and language_id = '" . (int)$languages_id . "'");

?>

<?php echo tep_draw_form('cart_quantity', tep_href_link('product_info.php', tep_get_all_get_params(array('action')). 'action=add_product', 'NONSSL'), 'post', 'class="form-horizontal" role="form"'); ?>

<?php
  if ($messageStack->size('product_action') > 0) {
    echo $messageStack->output('product_action');
  }
?>

<div class="contentContainer">

  <div class="row is-product">
    <?php echo $oscTemplate->getContent('product_info'); ?>
  </div>

</div>

</form>

<?php
  }
  require('includes/template_bottom.php');
  require('includes/application_bottom.php');
?>

Not wanting to "crash" the rest of MY TEST STORE (am upgrading)  I must ask

Where does the required coding go?

Thank you in advance

BJ

Link to comment
Share on other sites

  • 6 months later...

Hello,
Did anyone got this working on Phoenix??
some of change code it can done by new modules and the class files can go to override ,, but the changes on catalog/checkout_shipping.php hard to find !!

any tips

Br
Omar

 

Get the latest Responsive osCommerce CE (community edition) here .

Link to comment
Share on other sites

Create a checkout_shipping, injectRedirects hook. 

public function listen_injectRedirects() {
  $GLOBALS['products_ship_free'] = false;
  if (!GLOBALS['free_shipping']) {
    define('TEXT_CHOOSE_SHIPPING_METHOD', TEXT_CHOOSE_SHIPPING_METHOD_NO_PFS);
    define('TEXT_ENTER_SHIPPING_INFORMATION', TEXT_ENTER_SHIPPING_INFORMATION_NO_PFS);
    return;
  }

  foreach ($_SESSION['cart']->get_products() as $product) {
    if (1 == $product['ship_free']) {
      $ship_free_count += $product['quantity'];
    }
  }

  if (($GLOBALS['total_weight'] == 0) && ($GLOBALS['total_count'] == 0)) {
    $products_ship_free = true;
    $GLOBALS['free_shipping'] = true;
    if (!defined('FREE_SHIPPING_TITLE')) {
      include 'includes/languages/' . $_SESSION['language'] . '/modules/order_total/ot_shipping.php';
    }
  }

  define('TEXT_CHOOSE_SHIPPING_METHOD', ($products_ship_free ? sprintf(PRODUCTS_SHIP_FREE_COUNT, $ship_free_count); : TEXT_CHOOSE_SHIPPING_METHOD_NO_PFS));
  define('TEXT_ENTER_SHIPPING_INFORMATION', ((!$products_ship_free && ($ship_free_count > 0)) ? sprintf(PRODUCTS_SHIP_FREE_COUNT_ONLY, $ship_free_count) : TEXT_ENTER_SHIPPING_INFORMATION_NO_PFS));
}

or similar.  In the language files for that page, for each language, change TEXT_CHOOSE_SHIPPING_METHOD to TEXT_CHOOSE_SHIPPING_METHOD_NO_PFS and TEXT_ENTER_SHIPPING_INFORMATION to TEXT_ENTER_SHIPPING_INFORMATION_NO_PFS. 

In your overridden shopping_cart class, also change

    function count_contents() {
      $total_items = 0;
      if (is_array($this->contents)) {
        foreach (array_keys($this->contents) as $products_id) {
          $total_items += $this->get_quantity($products_id);
        }
      }

      return $total_items;
    }

to

    function count_contents() {
      $total_items = 0;
      if (is_array($this->contents)) {
        foreach ($this->contents as $products_id => $product) {
          if (1 != $product['ship_free']) {
            $total_items += $this->get_quantity($products_id);
          }
        }
      }

      return $total_items;
    }

and change in the calculate function

          $this->weight += ($qty * $products_weight);

to

          if (1 != $this->contents[$products_id]['ship_free']) {
            $this->weight += ($qty * $products_weight);
          }

That should cover the checkout_shipping instructions Lambros posted.  There may be other changes necessary to other files that are not included here.  For example, there are other changes to the shopping_cart class posted in the instructions.  And the catalog/shopping_cart.php change would now be made in includes/modules/content/shopping_cart/templates/tpl_cm_sc_product_listing.php

Replace

    echo   '<th><a href="' . tep_href_link('product_info.php', 'products_id=' . $product['id']) . '">' . $product['name'] . '</a>';
    foreach (($product['attributes'] ?? []) as $option => $value) {

with

    echo   '<th><a href="' . tep_href_link('product_info.php', 'products_id=' . $product['id']) . '">' . $product['name'] . '</a>';
    if (1 == $product['ship_free']) {
      echo '<br /><span class="smallText">(' . TEXT_PRODUCT_SHIPS_FREE . ')</span>';
    }
    foreach (($product['attributes'] ?? []) as $option => $value) {

That's three lines added between two existing lines. 

Hopefully that will be enough to get you going.  @Omar_one

Always back up before making changes.

Link to comment
Share on other sites

  • 2 weeks later...

I made a mistake in the second line. 

public function listen_injectRedirects() {
  $products_ship_free = false;
  if (!GLOBALS['free_shipping']) {
    define('TEXT_CHOOSE_SHIPPING_METHOD', TEXT_CHOOSE_SHIPPING_METHOD_NO_PFS);
    define('TEXT_ENTER_SHIPPING_INFORMATION', TEXT_ENTER_SHIPPING_INFORMATION_NO_PFS);
    return;
  }

  foreach ($_SESSION['cart']->get_products() as $product) {
    if (1 == $product['ship_free']) {
      $ship_free_count += $product['quantity'];
    }
  }

  if (($GLOBALS['total_weight'] == 0) && ($GLOBALS['total_count'] == 0)) {
    $products_ship_free = true;
    $GLOBALS['free_shipping'] = true;
    if (!defined('FREE_SHIPPING_TITLE')) {
      include 'includes/languages/' . $_SESSION['language'] . '/modules/order_total/ot_shipping.php';
    }
  }

  define('TEXT_CHOOSE_SHIPPING_METHOD', ($products_ship_free ? sprintf(PRODUCTS_SHIP_FREE_COUNT, $ship_free_count); : TEXT_CHOOSE_SHIPPING_METHOD_NO_PFS));
  define('TEXT_ENTER_SHIPPING_INFORMATION', ((!$products_ship_free && ($ship_free_count > 0)) ? sprintf(PRODUCTS_SHIP_FREE_COUNT_ONLY, $ship_free_count) : TEXT_ENTER_SHIPPING_INFORMATION_NO_PFS));
}

Note that this assumes that you've modified the shoppingCart->get_products method to return the 'ship_free' column. 

Always back up before making changes.

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...