path problem for add to cart button

Hi there, i follow a tutorial from www.phpwebcommerce.com and i’m having path problem for ‘add to cart’ button.

Demo from phpwebcommerce: http://www.phpwebcommerce.com/plaincart/index.php
I have modified some changes, i’m putting the ‘add to cart’ button to 1st level instead of 2nd level. Example, under all category (car & manga) i choose car, then inside car category list there is a ‘add to cart’ button under all car product instead of clicking inside and show ‘add to cart’ button.

productDetail.php:
[php]

<?php if (!defined('WEB_ROOT')) { exit; } $product = getProductDetail($pdId, $catId); // we have $pd_name, $pd_price, $pd_description, $pd_image, $cart_url extract($product); ?>
<?php echo $pd_name; ?> <?php echo $pd_name; ?>
Price : <?php echo displayAmount($pd_price); ?>
<?php // if we still have this product in stock // show the 'Add to cart' button if ($pd_qty > 0) { ?> <?php } else { echo 'Out Of Stock'; } ?>
<?php echo $pd_description; ?>
[/php]

I copy this code out from productDetail.php:

<input type="button" name="btnAddToCart" value="Add To Cart &gt;" onClick="window.location.href='<?php echo $cart_url; ?>';">

productList.php:
[php]

<?php if (!defined('WEB_ROOT')) { exit; } $productsPerRow = 2; $productsPerPage = 8; //$productList = getProductList($catId); $children = array_merge(array($catId), getChildCategories(NULL, $catId)); $children = ' (' . implode(', ', $children) . ')'; $sql = "SELECT pd_id, pd_name, pd_price, pd_thumbnail, pd_qty, c.cat_id FROM tbl_product pd, tbl_category c WHERE pd.cat_id = c.cat_id AND pd.cat_id IN $children ORDER BY pd_name"; $result = dbQuery(getPagingQuery($sql, $productsPerPage)); $pagingLink = getPagingLink($sql, $productsPerPage, "c=$catId"); $numProduct = dbNumRows($result); // the product images are arranged in a table. to make sure // each image gets equal space set the cell width here $columnWidth = (int)(100 / $productsPerRow); ?> <?php if ($numProduct > 0 ) { $i = 0; while ($row = dbFetchAssoc($result)) { extract($row); if ($pd_thumbnail) { $pd_thumbnail = WEB_ROOT . 'images/product/' . $pd_thumbnail; } else { $pd_thumbnail = WEB_ROOT . 'images/no-image-small.png'; } if ($i % $productsPerRow == 0) { echo ''; } // format how we display the price $pd_price = displayAmount($pd_price); echo " <?php } ?>

$pd_name

Price : $pd_price
";
	// if the product is no longer in stock, tell the customer
	if ($pd_qty <= 0) {
		echo "<br>Out Of Stock";
	}
	
	echo "</td>\r\n";

	if ($i % $productsPerRow == $productsPerRow - 1) {
		echo '</tr>';
	}
	
	$i += 1;
}

if ($i % $productsPerRow > 0) {
	echo '<td colspan="' . ($productsPerRow - ($i % $productsPerRow)) . '">&nbsp;</td>';
}

} else {
?>

No products in this category

<?php echo $pagingLink; ?>

[/php]

The code i copy from productDetail.php i paste in productList.php at line48, it show the ‘add to cart’ button but when i click on it, it cant add to my shopping cart and it show error:

Notice: Undefined variable: cart_url in C:\Domains\xxxxxxxx\wwwroot\xxxxxxxx\plaincart\include\productList.php on line 48
Notice: Undefined variable: cart_url in C:\Domains\xxxxxxxx\wwwroot\xxxxxxxx\plaincart\include\productList.php on line 48
Notice: Undefined variable: cart_url in C:\Domains\xxxxxxxx\wwwroot\xxxxxxxx\plaincart\include\productList.php on line 48
Notice: Undefined variable: cart_url in C:\Domains\xxxxxxxx\wwwroot\xxxxxxxx\plaincart\include\productList.php on line 48

Will Appreciate For Any Help…Thank you in advanced & sorry for the bad English.

Sponsor our Newsletter | Privacy Policy | Terms of Service