Tom Muck

Alpha Dog Blues Band
Home page
All articles
All Extensions | Extension News | Extension FAQs | Customer Login
Books authored or co-authored by Tom Muck
Extensions, books, and other products | Customer Login
Your current cart contents
Tom-Muck.com Blog | CMXTraneous Blog | Flash Remoting Blog
About the site

Display Add To Cart Results

Displaying an Add To Cart link in the Results Page

Since products can have multiple skus, there is not a simple method to display all skus with an add to cart link on the results page. However, if you have a store with one sku per product, it is simple enough. Make a function at the top of the page to grab the sku for each product:

function getSku($productId) {
 global $cartweaver;
 /* Get SKU Data */
 $query_rsCWGetSKUs = "SELECT SKU_ID
 FROM tbl_skus
 WHERE SKU_ProductID = $productId";
 $rsCWGetSKUs = $cartweaver->db->executeQuery($query_rsCWGetSKUs);
 $rsCWGetSKUs_recordCount = $cartweaver->db->recordCount;
 $row_rsCWGetSKUs = $cartweaver->db->db_fetch_assoc($rsCWGetSKUs);
 return $row_rsCWGetSKUs['SKU_ID'];
}

then in the results loop, probably in a table cell:

<a href="details.php?prodId=<?php echo($row_rsCWResults["product_ID"]);?>&amp;skuid=<?php echo(getSku($row_rsCWResults["product_ID"]));?>&amp;addtocart=true">Add to Cart</a>

Make sure you are using Cartweaver 2.5.2 or higher, as previous versions did not have the ability to pass information to the cart on the URL.

Back to Cartweaver PHP FAQ, code changes, and samples

Pay me securely with your Visa, MasterCard, Discover, or American Express card through PayPal!
Pay me securely with your Visa, MasterCard, Discover, or American Express card through PayPal!
About | Privacy Policy | Contact | License Agreement | ©2002-2025 Tom Muck | Dreamweaver Extensions