1

I am creating a module that display a custom add to cart button for each item i fetch from DB. ( I don't want to use ubercart but rather a custom simple cart).

So my code looks like this: mycustom_page() {

$sql = "SELECT nid from {nodes} n WHERE n.type = :type AND n.status = :status";
$result = db_query($sql, array(
'type' => 'products',
'status' => 1,
));
foreach($result as $row) {
$node = node_load($row->nid);
$page[query'][] = node_view($node, 'teaser');

return $page;

}

this will return a list of nodes of type products. All I need now is to add a form with a add to cart button and a callback with add to cart feature.

How do I add a form to each node? Also I need if is possible to display and handle the node fields separately inside the foreach.

Many thanks

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.