4 replies [Last post]
BigMike's picture
Offline
Joined: 10/20/2008
Juice: 1057
Was this information Helpful?

Hello UC,

I need to do something that Views cannot provide for me, so I am going old school with my own PHP.

Important: I am doing this through a block that I am displaying on product pages beneath the product currently being viewed.

To get most of the data without doing a bunch of queries, I am using
node_load($my_variable, NULL, FALSE);

where my_variable is the node ID I am loading.

Usually, to get the shopping cart links through my node-product-tpl.php I'd use

->content['add_to_cart']["#value"];

but this doesn't return anything after using node_load in my block. So I tried another method I know of,

->[body];

But this only returns the body itself without any cart links. I then used print_r to see what is available and the cart links are in fact absent from the entire loaded node array!

So I am wondering how can I get more data when I am working in a block and not in the theme template file? I really don't want to make a bunch of queries to manually code HTML for the cart links because I am using AJAX cart and AJAX attribute calculations modules, and I haven't even looked into what HTML and Javascript I'll need to code to get the same function as if the node was being loaded by itself.

Thank you for your help!
Regards,
BigMike

BigMike's picture
Offline
Joined: 10/20/2008
Juice: 1057
BigMike wrote: I need to do
BigMike wrote:

I need to do something that Views cannot provide for me

More on this, and perhaps someone could help me on this alternative route.

What I tried to do with Views and failed is create a filter that will only return the nodes that are on the product's "Related products" list (via the Upsell module). I couldn't figure this out so I gave in to going old school.

If someone could supply a PHP argument for a View that would filter only nodes that are on the product's "Related products" list that would certainly make my life a whole lot easier Laughing out loud

BigMike's picture
Offline
Joined: 10/20/2008
Juice: 1057
Re: node_load doesn't include shopping cart links? Need help fin

(Is this community still alive?)

BigMike wrote:

If someone could supply a PHP argument for a View that would filter only nodes that are on the product's "Related products" list that would certainly make my life a whole lot easier Laughing out loud

I just figured out how to get what I needed using a View. It required a pretty complicated (for me) yet small PHP argument to extract matching nodes from the related_products table and return them as multiple terms for the View output.

So I got what I needed!

Thanks
Mike

BigMike's picture
Offline
Joined: 10/20/2008
Juice: 1057
Re: node_load doesn't include shopping cart links? [solved using

Hello UC (is anyone out there?)

I have another project that requires this functionality, but I won't be able to use Views this time.

BigMike wrote:

To get most of the data without doing a bunch of queries, I am using
node_load($my_variable, NULL, FALSE);

where my_variable is the node ID I am loading.

Usually, to get the shopping cart links through my node-product-tpl.php I'd use

->content['add_to_cart']["#value"];

but this doesn't return anything after using node_load in my block.

Can someone please explain to me how to load UC themed Shopping Cart links using PHP?

Thank you
BigMike

end user's picture
Offline
Joined: 01/11/2008
Juice: 1198
Re: Re: node_load doesn't include shopping cart links? [solved u

Not 100% but it think if you want to move it around its

Hide the field so its not printed

<?php hide($content['add_to_cart']);?>

and then reprint the field where you want it.

<?php print render($content['add_to_cart']);?>