Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Help with creating estimated shipping


ryanfc

Recommended Posts

I want to add a estimated shipping value on the shopping_cart.php page and was hoping someone can help me create the code for this. (There is only one product on the site and it will be the only product they sell on this site.) Right above Sub-Total I want to add Estimated Shipping which has a value of the quantity (ther user wants) times $24.95 (always $24.95). So when the user changes the quantity of the product and clicks the Update button the Estimated Shipping cost reflexs the new shipping cost as well. I am going to put a disclaimer on this page saying that this is just an estimate and a true value will be given once they fill out their address info. So I don't need this estimate value to carry through to other pages. Can anyone help me with adding code that does this. I have no idea how to do this but the client really wants this added and I really want my money. :) Thanks! If you have any questions for me just let me know.

 

You can see the site at http://www.gutterprotector.net then click on the purchase button (top right corner).

Link to comment
Share on other sites

On the shopping_cart.php page I have added this (at line 162):

 

	  $info_box_contents[$cur_row][] = array('align' => 'right',
										 'params' => 'class="productListing-data" valign="top"',
										 'text' => '<b>' . $currencies->display_price($products[$i]['shipping'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</b>');

 

I have also added a shipping field to the customers_basket in the database with the set value of 24.9500. Again i am not worried about this value continuing to other pages as this is just an estimate. I got the above code from copying the code for the "Total"

 

	  $info_box_contents[$cur_row][] = array('align' => 'right',
										 'params' => 'class="productListing-data" valign="top"',
										 'text' => '<b>' . $currencies->display_price($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</b>');

 

and just changed final_price to shipping. However as you can see it doesn't work. I have a feeling I need to change something in the code like $currencies or display price but when I do that I get this error:

 

Fatal error: Call to a member function on a non-object in /home/gutterpr/public_html/shopping/shopping_cart.php on line 164

 

Can anyone help me on how to fix this problem?????

Link to comment
Share on other sites

On the shopping_cart.php page I have added this (at line 162):

 

	  $info_box_contents[$cur_row][] = array('align' => 'right',
										 'params' => 'class="productListing-data" valign="top"',
										 'text' => '<b>' . $currencies->display_price($products[$i]['shipping'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</b>');

 

I have also added a shipping field to the customers_basket in the database with the set value of 24.9500. Again i am not worried about this value continuing to other pages as this is just an estimate. I got the above code from copying the code for the "Total"

 

	  $info_box_contents[$cur_row][] = array('align' => 'right',
										 'params' => 'class="productListing-data" valign="top"',
										 'text' => '<b>' . $currencies->display_price($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . '</b>');

 

and just changed final_price to shipping. However as you can see it doesn't work. I have a feeling I need to change something in the code like $currencies or display price but when I do that I get this error:

Can anyone help me on how to fix this problem?????

 

way too complicated.

 

shopping_cart.php:

 

before:

 

$products = $cart->get_products();

for ($i=0, $n=sizeof($products); $i<$n; $i++) {

 

add:

 

$cart_qty = 0;

 

after:

 

$products = $cart->get_products();

for ($i=0, $n=sizeof($products); $i<$n; $i++) {

 

add:

 

$cart_qty = $cart_qty + $products[$i]['quantity'];

 

 

replace :

 

<tr>

<td align="right" class="main"><b><?php echo SUB_TITLE_SUB_TOTAL; ?> <?php echo $currencies->format($cart->show_total()); ?></b></td>

</tr>

 

with:

<?php $est_ship = $cart_qty * 24.95; ?>

<tr>

<td align="right" class="main"><b><?php echo 'Estimated Shipping:'; ?> <?php echo $currencies->format($est_ship ); ?></b></td>

</tr>

<tr>

<td align="right" class="main"><b><?php echo SUB_TITLE_SUB_TOTAL; ?> <?php echo $currencies->format($cart->show_total()+$est_ship ); ?></b></td>

</tr>

Treasurer MFC

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...