Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Carrying a variable from 1 page to another


TerryK

Recommended Posts

I'm using the 'Product Availability' mod and love the functionality. I'd like to carry the status wording over to the shopping cart page, but can't figure out how to do it, and haven't had a response in the contrib's forum. I have this question related to other fields, too, so perhaps it isn't mod-specific and maybe someone out there can help me? ( She says with a heart-full-of-hope! ) :)

 

Per the instructions, in product_info.php, I had to amend $product_info_query= tep_db_query to include the new fields, like so:

 

    $product_info_query = tep_db_query("select p.products_id, p.products_weight, 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_availability_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['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);

 

and also added these definitions (not sure if that's the right terminology or not):

 

    $products_availability = $product_info['products_availability_id'];

   $products_availability_info_query = tep_db_query("select e.products_availability_name from " . TABLE_PRODUCTS_AVAILABILITY . " e where e.products_availability_id = '" . (int)$products_availability . "' and e.language_id = '" . (int)$languages_id . "'");

   $products_availability_info = tep_db_fetch_array($products_availability_info_query);
   $products_availability_name = $products_availability_info['products_availability_name'];
?>
<?php
   if (tep_not_null($product_info['products_image'])) {
?>

<?php
  if (tep_not_null($products_availability_info['products_availability_name'])) {
?>

 

Then, where I want the availability message displayed, I add this code:

 

<?php echo TEXT_AVAILABILITY; ?>*:</b><BR>
<?php echo $products_availability_name; ?>

 

In shopping_cart.php, I don't see the $product_info_query = tep_db_query statement, so I don't know how to manipulate it. I'd like to add my availability code within this snippet of HTML where noted in red:

 

' <td class="productListing-data2" valign="top"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '"><b>' . $products[$i]['name'] . '</b></a>';

 

if (STOCK_CHECK == 'true') {

$stock_check = tep_check_stock($products[$i]['id'], $products[$i]['quantity']);

if (tep_not_null($stock_check)) {

$any_out_of_stock = 1;

 

$products_name .= $stock_check;

}

}

 

if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {

reset($products[$i]['attributes']);

while (list($option, $value) = each($products[$i]['attributes'])) {

$products_name .= '<br><small><i> - ' . $products[$i][$option]['products_options_name'] . ' ' . $products[$i][$option]['products_options_values_name'] . '</i></small>';

}

}

 

$products_name .= ' <?php echo TEXT_AVAILABILITY; ?>*:</b><BR>

<?php echo $products_availability_name; ?></td>' .

' </tr>' .

'</table>';

 

 

When I add that, all it displays is the '*:' part of the code shown above, so I'm obviously doing something wrong.

 

I will be eternally grateful if someone can help me figure this out!

 

TIA,

 

Terry

Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Link to comment
Share on other sites

Add it to the function get_products() query and $products_array in catalog/includes/classes/shopping_cart.php - then you can call it with:

 

$products[$i]['products_availability_name']

 

HTH

 

Matti

Link to comment
Share on other sites

Matti, thanks for your help!

 

I managed to add the code to catalog/includes/classes/shopping_cart.php without causing a crash, but I'm getting parse errors when I try to add the line of code into /catalog/shopping_cart.php. Here's the modified code from /classes/shopping_cart.php (my mod's in red):

 

function get_products() {

global $languages_id;

 

if (!is_array($this->contents)) return false;

 

$products_array = array();

reset($this->contents);

while (list($products_id, ) = each($this->contents)) {

$products_query = tep_db_query("select p.products_id, pd.products_name, p.products_model, p.products_image, p.products_price, p.products_weight, p.products_tax_class_id, p.products_availability_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$products_id . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");

if ($products = tep_db_fetch_array($products_query)) {

$prid = $products['products_id'];

$products_price = $products['products_price'];

 

$products_availability = $product_info['products_availability_id'];

 

$products_availability_info_query = tep_db_query("select e.products_availability_name from " . TABLE_PRODUCTS_AVAILABILITY . " e where e.products_availability_id = '" . (int)$products_availability . "' and e.language_id = '" . (int)$languages_id . "'");

 

$products_availability_info = tep_db_fetch_array($products_availability_info_query);

$products_availability_name = $products_availability_info['products_availability_name'];

?>

<?php

if (tep_not_null($product_info['products_image'])) {

?>

 

<?php

if (tep_not_null($products_availability_info['products_availability_name'])) {

?>

 

$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'];

}

 

$products_array[] = array('id' => $products_id,

'name' => $products['products_name'],

'model' => $products['products_model'],

'image' => $products['products_image'],

 

'availability' => $products[$i]['products_availability_name'],

'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'],

'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''));

}

}

 

return $products_array;

}

 

Then, in /catalog/shopping_cart.php, I added this:

 

if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {

reset($products[$i]['attributes']);

while (list($option, $value) = each($products[$i]['attributes'])) {

$products_name .= '<br><small><i> - ' . $products[$i][$option]['products_options_name'] . ' ' . $products[$i][$option]['products_options_values_name'] . '</i></small>';

}

}

 

$products_name .= $products[$i]['products_availability_name'];

 

$products_name .= ' </td>' .

' </tr>' .

'</table>';

 

 

When I test it, I get this error:

 

Parse error: parse error in /raid/home/mydomain/mydomain/catalog/includes/classes/shopping_cart.php on line 397

 

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /raid/home/mydomain/mydomain/catalog/includes/classes/shopping_cart.php:397) in /raid/home/mydomain/mydomain/catalog/includes/functions/sessions.php on line 67

 

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /raid/home/mydomain/mydomain/catalog/includes/classes/shopping_cart.php:397) in /raid/home/mydomain/mydomain/catalog/includes/functions/sessions.php on line 67

 

Fatal error: Cannot instantiate non-existent class: shoppingcart in /raid/home/mydomain/mydomain/catalog/includes/application_top.php on line 253

 

My /classes/shopping_cart.php file only has 396 lines, so I'm not sure what the error is there.

 

In includes/application_top.php, here are lines 253-271:

 

 

if ($SESSION_IP_ADDRESS != $ip_address) {

tep_session_destroy();

tep_redirect(tep_href_link(FILENAME_LOGIN));

}

}

 

// create the shopping cart & fix the cart if necesary

if (tep_session_is_registered('cart') && is_object($cart)) {

if (PHP_VERSION < 4) {

$broken_cart = $cart;

$cart = new shoppingCart;

$cart->unserialize($broken_cart);

}

} else {

tep_session_register('cart');

$cart = new shoppingCart;

}

 

 

Can anyone tell me what I'm doing wrong here?

 

TIA,

 

Terry

Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Link to comment
Share on other sites

This:

 

'availability' => $products[$i]['products_availability_name'],

 

should be:

 

'availability' => $products['products_availability_name'],

 

 

What are you trying to do with these? -:

 

<?php
if (tep_not_null($product_info['products_image'])) {
?>

<?php
if (tep_not_null($products_availability_info['products_availability_name'])) {
?>

 

They should both specify an output and be closed with curly brackets '}' - the most likely cause of your parse error - they don't belong in your classes/shopping_cart.php, but rather on the page you wish to display the info.

 

Matti

Link to comment
Share on other sites

Matti, thanks for your reply (again).

 

This:

 

'availability' => $products[$i]['products_availability_name'],

 

should be:

 

'availability' => $products['products_availability_name'],

 

Okay, I changed that.

 

What are you trying to do with these? -:

 

<?php
if (tep_not_null($product_info['products_image'])) {
?>

<?php
if (tep_not_null($products_availability_info['products_availability_name'])) {
?>

 

Ummm, I dunno? :)

 

They were in the original code, so I thought I had to add them with the other stuff... ( I am by NO means good at this PHP stuff, but I'm trying!!! )

 

Removing them and the following '?>' on the next line has removed the parse error, but the availability message still isn't displaying. (If I need to add it to the catalog/shopping_cart.php page, I'm not sure how to do that, or where it should go, so I've just left it out.)

 

Here's the relevant code I have now:

 

In /catalog/includes/classes/shopping_cart.php:

 

 ? ? ? ? ?$products_array[] = array('id' => $products_id,
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'name' => $products['products_name'],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'model' => $products['products_model'],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'image' => $products['products_image'],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'availability' => $products['products_availability_name'], ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'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'],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''));
? ? ? ?}
? ? ?}

? ? ?return $products_array;
? ?}

 

and in /catalog/shopping_cart.php:

 

 ? ? ?if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
? ? ? ?reset($products[$i]['attributes']);
? ? ? ?while (list($option, $value) = each($products[$i]['attributes'])) {
? ? ? ? ?$products_name .= '<br><small><i> - ' . $products[$i][$option]['products_options_name'] . ' ' . $products[$i][$option]['products_options_values_name'] . '</i></small>';
? ? ? ?}
? ? ?}

? ? ?$products_name .= $products[$i]['products_availability_name'];

? ? ?$products_name .= ' ? ?</td>' .
? ? ? ? ? ? ? ? ? ? ? ?' ?</tr>' .
? ? ? ? ? ? ? ? ? ? ? ?'</table>';

 

I don't know what I'm doing wrong -- any idea?

 

TIA,

 

Terry

Terry Kluytmans

 

Contribs Installed: Purchase Without Account (PWA); Big Images, Product Availability, Description in Product Listing, Graphical Infobox, Header Tags Controller, Login Box, Option Type Feature, plus many layout changes & other mods of my own, like:

 

Add order total to checkout_shipment

Add order total to checkout_payment

Add radio buttons at checkout_shipping (for backorder options, etc.)

Duplicate Table Rate Shipping Module

Better Product Review Flow

 

* If at first you don't succeed, find out if there's a prize for the loser. *

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...