Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Looking for guidance with shipping module


Guest

Recommended Posts

I apologize that I'm a newbie to oscommerce, php, and mysql. Over the past few months I have been reading allot of your forum postings and been building a new site, learning as I go. Using the newest 2.x version, I have successful installed the sts template system, at least I think I have; as well as easy populate, product extra fields, margin report and possibly a few others I can't remember. I have spent weeks trying to install the individual shipping module as well as the newest usps module without success.

 

Individual shipping module:

I have installed the last three updates dated: 12/5/2009 ; 12/14/2009 ; 07/22/2010. I was finally able to get the fields to show up in the product catalog admin page but all 3 fields (shipping zip code, shipping price, each additional price) all have text next to the input box that says "null". The fields will not save when I enter data. Nor if i use easy populate, will they save. Honestly, I'm not quite sure which code to even look at. I have included code for the admin/categories.php as well as the admin/includes/database_tables.php If someone could give me a hand i would greatly appreciate it. Thanks in advance.

 

Also, I did run the sql script and create the table. It did not specify a key or primary. I have tried adding the ID as both also without success.

 

...Seams the code is too long to place in this post. I can send it so someone to look at via email or i will try to post it in a reply.

Link to comment
Share on other sites

Or at least snip its of the appropriate code...

 

First the admin/catagories.php

 

         if (isset($HTTP_GET_VARS['pID'])) {
           tep_set_product_status($HTTP_GET_VARS['pID'], $HTTP_GET_VARS['flag']);
         }
// start indvship
         $sql_shipping_array = array('products_ship_zip' => tep_db_prepare_input($_POST['products_ship_zip']),
'products_ship_methods_id' => tep_db_prepare_input($_POST['products_ship_methods_id']),
'products_ship_price' => round(tep_db_prepare_input($_POST['products_ship_price']),4),
'products_ship_price_two' => round(tep_db_prepare_input($_POST['products_ship_price_two']),4));
         $sql_shipping_id_array = array('products_id' => (int)$products_id); 
         $products_ship_query = tep_db_query("SELECT * FROM " . TABLE_PRODUCTS_SHIPPING . " WHERE products_id = " . (int)$products_id);
         if(tep_db_num_rows($products_ship_query) >0) {
           if (($_POST['products_ship_zip'] == '')&&($_POST['products_ship_methods_id'] == '')&&($_POST['products_ship_price'] == '')&&($_POST['products_ship_price_two'] == '')){
             tep_db_query("DELETE FROM " . TABLE_PRODUCTS_SHIPPING . " where products_id = '" . (int)$products_id . "'");
           } else {
             tep_db_perform(TABLE_PRODUCTS_SHIPPING, $sql_shipping_array, 'update', "products_id = '" . (int)$products_id . "'");
           }
         } else {
           if (($_POST['products_ship_zip'] != '')||($_POST['products_ship_methods_id'] != '')||($_POST['products_ship_price'] != '')||($_POST['products_ship_price_two'] != '')){
             $sql_ship_array = array_merge($sql_shipping_array, $sql_shipping_id_array);
             tep_db_perform(TABLE_PRODUCTS_SHIPPING, $sql_ship_array, 'insert');
           }
         }
         // end indvship
         if (USE_CACHE == 'true') {
           tep_reset_cache_block('categories');

 

              tep_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description, products_url, products_viewed) values ('" . (int)$dup_products_id . "', '" . (int)$description['language_id'] . "', '" . tep_db_input($description['products_name']) . "', '" . tep_db_input($description['products_description']) . "', '" . tep_db_input($description['products_url']) . "', '0')");
           }
// start indvship
           $shipping_query = tep_db_query("select products_ship_methods_id, products_ship_zip from " . TABLE_PRODUCTS_SHIPPING . " where products_id = '" . (int)$products_id . "'");
           while ($shipping = tep_db_fetch_array($shipping_query)) {
             tep_db_query("insert into " . TABLE_PRODUCTS_SHIPPING . " (products_id, products_ship_methods_id, products_ship_zip) values ('" . (int)$dup_products_id . "', '" . tep_db_input($shipping['products_ship_methods_id']) . "', '" . tep_db_input($shipping['products_ship_zip']) . "')");
           } 
		// end indvship
           tep_db_query("insert into " . TABLE_PRODUCTS_TO_CATEGORIES . " (products_id, categories_id) values ('" . (int)$dup_products_id . "', '" . (int)$categories_id . "')");
           $products_id = $dup_products_id;

 

  $pInfo = new objectInfo($parameters);   

if (isset($HTTP_GET_VARS['pID']) && empty($HTTP_POST_VARS)) {
// start indvship
     $products_shipping_query = tep_db_query("SELECT * FROM " . TABLE_PRODUCTS_SHIPPING . " WHERE products_id=" . (int)$_GET['pID']);
     while ($products_shipping = tep_db_fetch_array($products_shipping_query)) {
       $products_ship_zip = $products_shipping['products_ship_zip'];
       $products_ship_methods_id = $products_shipping['products_ship_methods_id'];
       $products_ship_price = $products_shipping['products_ship_price'];
       $products_ship_price_two = $products_shipping['products_ship_price_two'];
     }
     $shipping=array('products_ship_methods_id' => $products_ship_methods_id,
     'products_ship_zip' => $products_ship_zip,
     'products_ship_price' => $products_ship_price,
     'products_ship_price_two' => $products_ship_price_two);
     $pInfo->objectInfo($shipping);
     // end indvship
// BOF Extra Fields Contribution	  
     $products_extra_fields_query = tep_db_query("SELECT * FROM " . TABLE_PRODUCTS_TO_PRODUCTS_EXTRA_FIELDS . " WHERE products_id=" . (int)$HTTP_GET_VARS['pID']);
     while ($products_extra_fields = tep_db_fetch_array($products_extra_fields_query)) {
       $extra_field[$products_extra_fields['products_extra_fields_id']] = $products_extra_fields['products_extra_fields_value'];
     }
  $extra_field_array=array('extra_field'=>$extra_field);
  $pInfo->objectInfo($extra_field_array);
// EOF Extra Fields Contribution

    $product_query = tep_db_query("select pd.products_name, pd.products_description, pd.products_url, p.products_id, p.products_quantity, p.products_model, p.products_image, p.products_price, p.products_cost, p.products_weight, p.products_date_added, p.products_last_modified, date_format(p.products_date_available, '%Y-%m-%d') as products_date_available, p.products_status, p.products_tax_class_id, p.manufacturers_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$HTTP_GET_VARS['pID'] . "' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'");
    $product = tep_db_fetch_array($product_query);

 

   <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
         </tr>
<!--start indvship-->
				<!-- Zipcode -->
				<tr bgcolor="#ebebff">
					<td class="main"><?php echo TEXT_PRODUCTS_ZIPCODE; ?></td>
					<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_ship_zip', $pInfo->products_ship_zip); if(tep_not_null($pInfo->products_ship_zip)) echo 'notnull'; else echo 'null'; ?></td>
				</tr>
				<!-- end Zipcode -->
				<!-- Indvship -->
				<tr bgcolor="#ebebff">
					<td class="main"><?php echo INDIV_SHIPPING_PRICE; ?></td>
					<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_ship_price', $pInfo->products_ship_price); if(tep_not_null($pInfo->products_ship_price)) echo 'notnull'; else echo 'null'; ?></td>
				</tr>
				<tr bgcolor="#ebebff">
					<td class="main"><?php echo EACH_ADDITIONAL_PRICE; ?></td>
					<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . ' ' . tep_draw_input_field('products_ship_price_two', $pInfo->products_ship_price_two); if(tep_not_null($pInfo->products_ship_price_two)) echo 'notnull'; else echo 'null'; ?></td>
				</tr>
				<!-- end Indvship -->
				<tr>
					<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
				</tr>
				<!--// end indvship-->
         <tr bgcolor="#ebebff">
           <td class="main"><?php echo TEXT_PRODUCTS_TAX_CLASS; ?></td>

Link to comment
Share on other sites

Now the admin/includes/databas_tables.php

 

  define('TABLE_PRODUCTS_OPTIONS_VALUES', 'products_options_values');
 define('TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS', 'products_options_values_to_products_options');
// start indvship
 define('TABLE_PRODUCTS_SHIPPING', 'products_shipping');
 // end indvship
 define('TABLE_PRODUCTS_TO_CATEGORIES', 'products_to_categories');
 define('TABLE_REVIEWS', 'reviews');
 define('TABLE_REVIEWS_DESCRIPTION', 'reviews_description');

Link to comment
Share on other sites

Or at least snip its of the appropriate code...

In the code there are several mentions of products_ship_methods_id but in the last piece of code that actually adds the input fields for the contribution this seems to be missing. Perhaps that gives an error when inserting or updating (is there an error file somewhere?).

 

The appearance of the text null or notnull is nothing to get worried about. It is coded in the contribution to show that but doesn't influence anything.

Link to comment
Share on other sites

Perhaps that gives an error when inserting or updating (is there an error file somewhere?).

 

It doesn't give an error when trying to insert or update the fields. They are just not here when I reload the page. I havn't found an error file anywhere, though, i'm not sure where to appropriately look.

 

 

In the code there are several mentions of products_ship_methods_id but in the last piece of code that actually adds the input fields for the contribution this seems to be missing.

 

Would you be able to show me how and where the code should look that is missing?

Link to comment
Share on other sites

It doesn't give an error when trying to insert or update the fields. They are just not here when I reload the page. I havn't found an error file anywhere, though, i'm not sure where to appropriately look.

 

Would you be able to show me how and where the code should look that is missing?

Perhaps you could tell what version of what addon exactly you are installing?

Link to comment
Share on other sites

Perhaps you could tell what version of what addon exactly you are installing?

 

Individual shipping module:

I have installed the last three updates dated: 12/5/2009 ; 12/14/2009 ; 07/22/2010

 

That would be the latest "Individual Product Shipping Prices - v.4.5 full" released on 12/5/2009, then updated with the "Easy Populate w/ Attribute for Individual Shipping Updated!" on 12/14/2009, and "Individual Product Shipping Prices - v.4.5 full - update" on 07/22/2010.

 

I'm using version oscommerce-2.2rc2a.I listed other modules I have installed in my original post. Is there anything else i can provide that would help? Thank you in advance for all your help.

Link to comment
Share on other sites

I took another look at the mysql database and noticed that i ran the sql a few times. This entered multiple "Individual_ship_home_country" and "Individual_Ship_Increase" values in the configuration table. I deleted all the individual ship values and ran the original sql again. Still no luck. I took a look at the products_shipping table and noticed there was no primary key again. I added the products_id field as the primary key. Still no luck. I went back through all the install files and made sure I modified them all correctly. Still no luck. I spent 3 more hours in addition to the previously mentioned time searching the Forums. I can't find anyone who had the same issue and i can't find where i've gone wrong. I am seriously pulling my hair out here.

Link to comment
Share on other sites

i can't find where i've gone wrong. I am seriously pulling my hair out here.

I have looked at 4.5 and 4.4 but for the life of me I can't find what the $products_ship_methods_id is supposed to do. This part seems a bit dodgy since if there is no entry for a products_id in the table products_shipping yet I can't find where the $_POST['products_ship_methods_id'] should come from. Perhaps this causes an error that you don't see.

 

You could try entering a row for a products_id in that table products_shipping and see if you can update it. Maybe this part should look for the existence of $_POST['products_ship_methods_id'] like for example (haven't tested it):

 


         // start indvship
         $sql_shipping_array = array('products_ship_zip' => tep_db_prepare_input($_POST['products_ship_zip']),
'products_ship_methods_id' => (isset($_POST['products_ship_methods_id']) ? tep_db_prepare_input($_POST['products_ship_methods_id']): ''),
'products_ship_price' => round(tep_db_prepare_input($_POST['products_ship_price']),4),
'products_ship_price_two' => round(tep_db_prepare_input($_POST['products_ship_price_two']),4));

Link to comment
Share on other sites

I have looked at 4.5 and 4.4 but for the life of me I can't find what the $products_ship_methods_id is supposed to do. This part seems a bit dodgy since if there is no entry for a products_id in the table products_shipping yet I can't find where the $_POST['products_ship_methods_id'] should come from. Perhaps this causes an error that you don't see.

 

The provided sql was:

 

DROP TABLE IF EXISTS `products_shipping`;
CREATE TABLE `products_shipping` (
`products_id` int(11) NOT NULL default '0',
`products_ship_methods_id` int(11) default NULL,
`products_ship_zip` varchar(32) default NULL,
`products_ship_price` varchar(10) default NULL,
`products_ship_price_two` varchar(10) default NULL
) TYPE=MyISAM;

INSERT INTO configuration VALUES ('', 'Indiv Ship Home Country', 'INDIVIDUAL_SHIP_HOME_COUNTRY', '223', 'Individual ship home country ID (other countries will have extra freight)', 7, NULL, '0000-00-00 00:00:00', '0000-00-00 00:00:00', NULL, NULL);
INSERT INTO configuration VALUES ('', 'Indiv Ship Outside Home Increase', 'INDIVIDUAL_SHIP_INCREASE', '3', 'Individual ship x increase for shipping outside home country. For example: If you set your item ship price to $50 and this value to 3 and ship outside your home country they will pay $150, and if this value was 2, they would pay $100.', 7, NULL, '0000-00-00 00:00:00', '0000-00-00 00:00:00', NULL, NULL);

 

It did not define a Primary key and where the code wasn't working I made the product id the key. If this actually did anything, i don't think so.

 

Wait a min..... I see your point now with the products_ship_methods_id.... Is there possibly a prerequisite module that i should have installed along with individual product shipping. Maybe one that chooses multiple shipping options and writes to the products_ship_methods_id? If i'm looking at this correctly now, their should be another table that contains the products_ship_methods_id and that column should also be indexed. Correct??

 

If that sounds write, maybe it's not saving my values because nothing is telling it to use the products_shipping table as the shipping info source??

 

Just to make sure i haven't mucked anything else in the admin panel turning this on. Under shipping modules, Individual Shipping - Zone 1 is installed. Tax Class --none-- shipping Zone --none-- Sort Order 0.

 

On the Configuration - Shipping/Packaging page, Indiv Ship Home Country - US, (I don't know what else to put there, it says country ID, but on the Locations/Taxes page - Countries page, United States says Name: United States, ISO Code (2) - US, ISO Code (3) - USA, Address Format - 2, it does not list "ID") Then the Indiv Ship Outside Home Increase is set to 3.

 

If products_ship_methods_id is not used, what table does the shipping info come from on the other built in shipping modules?

Link to comment
Share on other sites

  • 2 weeks later...

I'm still working to figure this issue out. I've taken the last advice from Zonjee and interpreted it as I may be missing a contribution. I looked for a contribution that may have the shipping_method included. I came across MVS v1.2.3 (Multi Vendor Shipping) and spent a few hours installing it. In the SQL it did list a (`shipping_method` varchar(128) NOT NULL default '')

 

Though I'm back where I started. Values still will not save. Is there anyone else out there that can help?

Link to comment
Share on other sites

  • 2 weeks later...

 

Though I'm back where I started. Values still will not save. Is there anyone else out there that can help?

I'll give it a try, though I'm a newbie to PHP, SQL, ... just like you. I had the same problem till I figured out that the installation instruction is not completely failproof - it says:

 

/catalog/admin/categories.php

-----------------------------

 

find:

 

if (USE_CACHE == 'true') {

tep_reset_cache_block('categories');

tep_reset_cache_block('also_purchased');

}

 

but the respective piece of code is used several times in this file. It worked for me after inserting the "add before"-code before the block in the following context:

 

          if (USE_CACHE == 'true') {
           tep_reset_cache_block('categories');
           tep_reset_cache_block('also_purchased');
         }

         tep_redirect(tep_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&pID=' . $products_id));
       }
       break;
     case 'copy_to_confirm':

 

In a fresh install, that means inserting it at line 267, I think. After that change, it worked in my shop. I don't know how that came to me but maybe it's 'Even a blind hen sometimes finds a grain of corn.'

 

Oliver

Link to comment
Share on other sites

 

In a fresh install, that means inserting it at line 267, I think. After that change, it worked in my shop. I don't know how that came to me but maybe it's 'Even a blind hen sometimes finds a grain of corn.'

 

Oliver

 

 

Well Oliver,

 

As far as I'm concerned, a blind hen can even become GOD with the right information. YOU DID IT!! That was the exact code I needed to concentrate on. I used WinMerge to compare what i had with the supplied admin/categories.php file and found issues with the exact code you mentioned. I also found an issue further along that was wrong as well, but what you mentioned above what the one causing the issue.

 

Thank You!!

 

Lesson learned here, I think i will be using WinMerg for all my module addons for now on.

Edited by eracer
Link to comment
Share on other sites

Does anyone here know why the module won't work?

 

It doesn't give me any errors, and it looks like I have saved everything. But, in the end, only the general module (under modules >> order total >> shipping) determines free shipping. I don't have two similar modules running at the same time, and i've tried to deactivate the 'general module" I just mentioned. And when I do, no free shipping.

 

Wouldn't I get an error message if this module was working properly?

Link to comment
Share on other sites

Does anyone here know why the module won't work?

 

It doesn't give me any errors, and it looks like I have saved everything. But, in the end, only the general module (under modules >> order total >> shipping) determines free shipping. I don't have two similar modules running at the same time, and i've tried to deactivate the 'general module" I just mentioned. And when I do, no free shipping.

 

Wouldn't I get an error message if this module was working properly?

 

 

I'd suggest going through the setup instructions. Make sure you put the country code in the settings that is listed in the instructions. (i almost missed that) Go though the last 3 updates posted on the oscommerce site, and use a compare program like winmerge to compare your files to the provided ones. The code that was mentioned in the last two post i don't even think was in the instructions. I didn't find the missing code until i did the file comparison. I'm not an expert by far, but this is what finally fixed my issue.

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