13 replies [Last post]
kulvik's picture
Offline
Uber DonorBug FinderEarly adopter... addicted to alphas.Cool profile pic award.Internationalizationizer
Joined: 08/14/2007
Juice: 336
Was this information Helpful?

Hi everyone.

I was just wondering if it's possible to add a product to cart without using the "add to cart" button/form? With the ecommerce package we used to just add a link to "cart/add/[nid]" to add a product to cart directly.

Thanks for any input.

______________
Thomas Kulvik
Ny Media AS
www.nymedia.no

kulvik's picture
Offline
Uber DonorBug FinderEarly adopter... addicted to alphas.Cool profile pic award.Internationalizationizer
Joined: 08/14/2007
Juice: 336
Re: Possible to add products to cart with text link?

bump? Sticking out tongue

blucches@drupal.org's picture
Offline
Bug FinderGetting busy with the Ubercode.
Joined: 08/08/2007
Juice: 30
Re: Re: Possible to add products to cart with text link?

The only problem I could see with that is that there is a function that is run that places an item into the cart and it looks at what attributes were chosen to be added into the cart.

kulvik's picture
Offline
Uber DonorBug FinderEarly adopter... addicted to alphas.Cool profile pic award.Internationalizationizer
Joined: 08/14/2007
Juice: 336
Re: Re: Re: Possible to add products to cart with text link?

Ok thanks. Guess i'll try adding multiple add to cart buttons instead Smiling

______________
Thomas Kulvik
Ny Media AS
www.nymedia.no

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6846
Re: Possible to add products to cart with text link?

I know Ryan's been working on something to that effect. Don't know how far he's gotten or how well it works. I'm not even sure I could find the files he's been working on.

Ah well, he'll come down from the mountains before too long.

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Re: Possible to add products to cart with text link?

Yo, looks like someone was looking for the Cart Links API while I was honeymooning? Well, it's been on my battle plans for a couple releases now, but I've yet to make it happen. It would be a fairly simple affair if someone wanted to write their own module to do it that I could incorporate into core. You would just have to copy the form submission code into a URL function... anyways, this may happen in the near future, but I need to get caught up first. Smiling

kulvik's picture
Offline
Uber DonorBug FinderEarly adopter... addicted to alphas.Cool profile pic award.Internationalizationizer
Joined: 08/14/2007
Juice: 336
Re: Re: Re: Possible to add products to cart with text link?

Ok, i'll see if we (Ny Media) can create a small module for this and send it over to you guys.

______________
Thomas Kulvik
Ny Media AS
www.nymedia.no

kulvik's picture
Offline
Uber DonorBug FinderEarly adopter... addicted to alphas.Cool profile pic award.Internationalizationizer
Joined: 08/14/2007
Juice: 336
Re: Re: Re: Possible to add products to cart with text link?

We needed this real quick so we just created a small "hack" for now. This solution does not take attributes into account Smiling

If you need a way to add products to cart quick and dirty just do this:

In uc_cart.module add this to hook_menu:

  } else {
   $items[] = array(
     'path' => 'cart/add',
     'title' => t('Add product to cart'),
     'callback' => 'uc_cart_add_simple',
     'access' => user_access('access content'),
     'type' => MENU_CALLBACK,
     'callback arguments' => array(arg(2)),
   );
}

And add this function to the same module:

function uc_cart_add_simple($nid) {
   $return = uc_cart_add_item($nid, 1);
   drupal_goto($return);
}

This is no final solution, but it works Eye-wink

______________
Best regards,
Thomas Kulvik
Ny Media AS
www.nymedia.no

quaoar's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Not Kulvik
Joined: 08/08/2007
Juice: 179
Nice coding Kulvik. Why do

Nice coding Kulvik.
Why do you have that else {} block there?
Usually you don't have that in the hook_menu(). None of the other items has an "else" there.

*sniggers*

Erlend Strømsvik
Ny Media AS
erlend@nymedia.no

kulvik's picture
Offline
Uber DonorBug FinderEarly adopter... addicted to alphas.Cool profile pic award.Internationalizationizer
Joined: 08/14/2007
Juice: 336
Re: Nice coding Kulvik. Why do

Lol.. you're just jealous because I managed to come up with this truly superior übercode Sticking out tongue

______________
Best regards,
Thomas Kulvik
Ny Media AS
www.nymedia.no

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Re: Nice coding Kulvik. Why do

No need for hacks any more: http://www.ubercart.org/contrib/1427 Eye-wink

kulvik's picture
Offline
Uber DonorBug FinderEarly adopter... addicted to alphas.Cool profile pic award.Internationalizationizer
Joined: 08/14/2007
Juice: 336
Re: Re: Re: Nice coding Kulvik. Why do

Excellent Ryan Smiling

leober's picture
Offline
Joined: 05/23/2011
Juice: 6
title links don't add product to the shooping cart

Hi Ryan,

I am trying this contribution that you are mentioning but I couldn't make it work.

So I added this to my node.tpl.php page cart/add/p24_q1?destination=cart but I need the p24 to be a variable because this only works with the product #24.

Thanks,

Leo

ñull@drupal.org's picture
Offline
Joined: 01/26/2009
Juice: 114
Ryan wrote: No need for hacks
Ryan wrote:

No need for hacks any more: http://www.ubercart.org/contrib/1427 Eye-wink

Where is this contribution now?