Jump to content


Corporate Sponsors


Latest News: (loading..)

* * * * * 2 votes

[contribution] individual product shipping prices


730 replies to this topic

#721 saupe31

  • Community Member
  • 52 posts
  • Real Name:carl

Posted 08 January 2012, 20:40

View Postskitom, on 17 December 2011, 18:54, said:

I have had individual shipping working for a month now. However i noticed people were not completing orders, i then found out my shipping was for some reason multiplied x3. (modules/shipping/indvship.php) It took me ages, i couldnt find where in the code the shipping was getting called 3 times, i eventually settled with using the higher shipping and adding code to only use 33.333333% of the high price, since i knew it was multiplied by 3.

$products = $cart->get_products();
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
if (tep_not_null($products[$i]['products_ship_price'])) {
$products_ship_price = $products[$i]['products_ship_price'];
$products_ship_price_two = $products[$i]['products_ship_price_two'];
$products_ship_zip = $products[$i]['products_ship_zip'];
$qty = $products[$i]['quantity'];
if(tep_not_null($products_ship_price) ||tep_not_null($products_ship_price_two)){
$shiptotal += ($products_ship_price)*0.333333333;
if ($qty > 1) {
if (tep_not_null($products_ship_price_two)) {
$shiptotal += ($products_ship_price_two * ($qty-1)*0.333333333);
} else {
$shiptotal += ($products_ship_price * ($qty-1)*0.333333333);


Im not sure why this happened, however i also experienced another issue where os commerce couldnt get pages for the front of house, while the admin worked fine. I found a soluion online, which stated it could be due to a php upgrade.

So most of my problems are fixed ive not gotta figure out how to fix
Fatal error: Cannot redeclare class zones on line 97. I think while trying to fix my above problem i must have accidentally changed a zone shipping file, so looks like its more time replacing files.
if you havent set your default region correctly it will mutliply by 3 #
You will need to configure: Admin panel > Configuration > Shipping / Packaging
#. You will need the correct Indiv Ship Home Country code
the country code are in the 4.3 doc

#722 saupe31

  • Community Member
  • 52 posts
  • Real Name:carl

Posted 08 January 2012, 20:44

View Postfan4chevy, on 07 November 2011, 06:31, said:

Is there anything planned for making this awesome mod work for 2.3? I really like this Contrib and I am hoping so.
i have installed it on a 2.3 store and its working fine
if you follow the 4.5 guide you will find it doesnt work, but the answers are in this thread for most of it and you can also use file compare software to match your files to the new install ones this is what i did

#723 saupe31

  • Community Member
  • 52 posts
  • Real Name:carl

Posted 09 January 2012, 06:17

View Postpsyphris, on 05 May 2010, 23:23, said:

I'm trying to implement this but it doesn't seem to work. Has something changed since this was created that would make it void?
if im correct you have to add this code to the indvship.php to
at line 71 $products = $cart->get_products(); below that

#724 saupe31

  • Community Member
  • 52 posts
  • Real Name:carl

Posted 09 January 2012, 07:46

catalog/includes/modules/shipping/indviship.php
so it would look like this
$products = $cart->get_products();
  // BB Start - Set first shipping price = second shipping price for all prods other than first prod with max shipping price - Start by determining index of max shipping price
$maxship = '0';
$i_maxship = 0;
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
if (($products[$i]['products_ship_price']) > $maxship) {
$maxship = ($products[$i]['products_ship_price']);
$i_maxship = $i;
}
}
// Here we set all ship prices to second ship price for entries other than the index determined above
for ($i=0, $n=sizeof($products); $i<$n; $i++) {
if ($i != $i_maxship) {
$products[$i]['products_ship_price'] = $products[$i]['products_ship_price_two'];
}
}
 
// BB End - Set first shipping price
   for ($i=0, $n=sizeof($products); $i<$n; $i++) {
	 if (tep_not_null($products[$i]['products_ship_price'])) {
	   $products_ship_price = $products[$i]['products_ship_price'];
	   $products_ship_price_two = $products[$i]['products_ship_price_two'];
	   $products_ship_zip = $products[$i]['products_ship_zip'];

Edited by saupe31, 09 January 2012, 07:58.


#725 fan4chevy

  • Community Member
  • 367 posts
  • Real Name:Charles

Posted 01 February 2012, 18:24

Hi all,

I installed this on 2.3.1 and all looked like it installed without a glitch execpt that after I put zip, ship, additional ship fields in admin and save, when I go back it is all blank, no shipping fees nor zip. Your help is appreciated.

Charles

#726 fan4chevy

  • Community Member
  • 367 posts
  • Real Name:Charles

Posted 02 February 2012, 06:40

Here is part of the answer listed by someone in this thread. However, still not showing up in the checkout.



There is a instruction in contribution name- 'How_To_Install_individual_shipping_4.5.txt'.
In that file find '/catalog/admin/categories.php'. then find

if (USE_CACHE == 'true') {
tep_reset_cache_block('categories');
tep_reset_cache_block('also_purchased');
}
but there is more then 1 statement like this on categories.php
You have to find -

if ($action == 'insert_product') {
$insert_sql_data = array('products_id' => $products_id,
'language_id' => $language_id);

$sql_data_array = array_merge($sql_data_array, $insert_sql_data);

tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array);
} elseif ($action == 'update_product') {
tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $sql_data_array, 'update', "products_id = '" . (int)$products_id . "' and language_id = '" . (int)$language_id . "'");
}
}

after above statement you have to insert

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

enjoy :thumbsup:

Edited by fan4chevy, 02 February 2012, 06:42.


#727 fan4chevy

  • Community Member
  • 367 posts
  • Real Name:Charles

Posted 02 February 2012, 08:04

I have the admin zip, ship1 and two saving in admin. However, I have been stumped trying to figure out why it is not showing up on frontpage checkout. No shipping fees, just 0. Your help is appreciated as I have checked all my back steps.

#728 fan4chevy

  • Community Member
  • 367 posts
  • Real Name:Charles

Posted 02 February 2012, 18:47

Hi,

I got the shipping prices to now show up in checkout. However, I get this error after selecting paypal payment method:

shopping_cart.php?error_message=A match of the Shipping Address City, State, and Postal Code failed.

Your help is appreciated. I am using osc 2.3.1

Edited by fan4chevy, 02 February 2012, 18:47.


#729 saupe31

  • Community Member
  • 52 posts
  • Real Name:carl

Posted 08 February 2012, 14:36

View Postkc3923, on 12 January 2009, 16:48, said:

Check to make sure you have included the following


In catalog\includes\classes\shopping_cart.php

Find

		  $specials_query = tep_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . (int)$prid . "' and status = '1'");		  if (tep_db_num_rows($specials_query)) {			$specials = tep_db_fetch_array($specials_query);			$products_price = $specials['specials_new_products_price'];		  }

Insert AFTER it

		  // start indvship		  $products_shipping_query = tep_db_query("select products_ship_price, products_ship_price_two, products_ship_zip, products_ship_methods_id from " . TABLE_PRODUCTS_SHIPPING . " where products_id = '" . $products['products_id'] . "'");		  $products_shipping = tep_db_fetch_array($products_shipping_query);		  // end indvship

Find

		 $products_array[] = array('id' => $products_id,									'name' => $products['products_name'],									'model' => $products['products_model'],									'image' => $products['products_image'],									'price' => $products_price,									'quantity' => $this->contents[$products_id]['qty'],									'weight' => $products['products_weight'],									'final_price' => ($products_price + $this->attributes_price($products_id)),									'tax_class_id' => $products['products_tax_class_id'],

Insert AFTER it

	  // start indvship		'products_ship_price' => $products_shipping['products_ship_price'],		'products_ship_price_two' => $products_shipping['products_ship_price_two'],		'products_ship_zip' => $products_shipping['products_ship_zip'],	// end  indvship

In catalog\includes\classes\order.php

Find
	  $this->info = array('order_status' => DEFAULT_ORDERS_STATUS_ID,						  'currency' => $currency,						  'currency_value' => $currencies->currencies[$currency]['value'],						  'payment_method' => $payment,

Insert BEFORE it

	  //start indvship	  if($shipping['id']==indvship_indvship){		$shipping_cost = $shipping['cost'];		$shipping_title = $shipping['title'];	  } else {		$shipping_cost = $shipping['cost'] + $shipping['invcost'];		if ($shipping['invcost'] > 0) {		  $shipping_title = $shipping['title']. ' Plus Flat Rate Shipping';		} else {		  $shipping_title = $shipping['title'];		}	  }	  // end indvship 

Find

						  'subtotal' => 0,						  'tax' => 0,						  'tax_groups' => array(),

Insert BEFORE it

			  // start indvship						  //'shipping_method' => $shipping['title'],						  //'shipping_cost' => $shipping['cost'],						  'shipping_method' => $shipping_title,						  'shipping_cost' => $shipping_cost, 			  //end indvship 



Hope that helps


#730 outdoorgeek

  • Community Member
  • 34 posts
  • Real Name:George
  • Gender:Male
  • Location:South Africa

Posted 28 February 2012, 15:49

Hi Guys

Just need some help here please. A qualified coder installed the latest version for me and all seems to be working fine except..

After allocating the shipping price of say $10 for an item (Admin>Catalog>Products>Edit), once I run a test purchase for this item, the shipping price of $10 doesn't show at checkout, it shows $0.

Any suggestions how I can rectify this?

Thx

#731 outdoorgeek

  • Community Member
  • 34 posts
  • Real Name:George
  • Gender:Male
  • Location:South Africa

Posted 29 February 2012, 06:34

View Postfan4chevy, on 02 February 2012, 08:04, said:

I have the admin zip, ship1 and two saving in admin. However, I have been stumped trying to figure out why it is not showing up on frontpage checkout. No shipping fees, just 0. Your help is appreciated as I have checked all my back steps.
fan4chevy, how did you resolve it as I am having the same problem - "0" value at checkout.
George