tags:

views:

34

answers:

1

I inherited a zencart mod and can't figure out what's wrong. The customer selects a product and an attribute (model#). This is then sent to another form that they complete. When they submit the form, the product and the attribute should be included in the email sent.

At this time, only the product is coming through. The attribute just says "array." The interesting part is, when I delete the line that prints the attribute, the products_options_names will print out. So I know that both the product and the products_options_names are working. The attribute is the only thing that is not working right.

Here's what I believe to be the significant code. This is the page that has the form, so the attribute should already be passed to the form.

//Begin Adding of New features
//$productsimage = $product['productsImage'];
$productsname = $product['productsName'];
$attributes = $product['attributes'];
$products_options_name = $value['products_options_name'];

$arr_product_list[] = "<strong>Product Name:</strong> $productsname <br />";
$arr_product_list[] .= "<strong>Attributes:</strong> $attributes <br />";
$arr_product_list[] .= "<strong>Products Options Name:</strong> $products_options_name  <br />";
$arr_product_list[] .=  "---------------------------------------------------------------";

//End  Adding of New features

  } // end foreach ($productArray as $product)
?>

Above this, there is another section that has attributes:

 <?php
   echo $product['attributeHiddenField'];
   if (isset($product['attributes']) && is_array($product['attributes'])) {
   echo '<div class="cartAttribsList">';
    echo '<ul>';
    reset($product['attributes']);
    foreach ($product['attributes'] as $option => $value) {
?>

Can anyone help me figure out what is wrong? I'm not sure if the problem is on this page or if the attribute isn't being passed to this page.

TIA

A: 

Your first snippet includes a potential issue. You're adding new items to the array $arr_product_list while also trying to use the string concatenation .= operator. This, of course, is confusing to PHP, since you're trying to add to a string that does not yet exist.

I believe the intent of your code is to build an HTML snippet and then add that to the array, which you could do with the following:

$str = "<strong>Product Name:</strong> $productsname <br />";
$str .= "<strong>Attributes:</strong> $attributes <br />";
$str .= "<strong>Products Options Name:</strong> $products_options_name  <br />";
$str .=  "---------------------------------------------------------------";
$arr_product_list[] = $str;

You're likely getting errors from PHP about this, but perhaps they're suppressed. Double-check your php.ini and make sure your error_reporting, display_errors, display_startup_errors and log_errors settings are correct.

awgy
Unfortunately that made no difference. The Attributes still just says "array."What's weird is the $product['attributes'] is used to print it out on the page. I don't get why it's empty later.
and if I change this: $attributes = $product['attributes']; to $attributes = $value;it still says "Array"