URL API

Posts: 15
Joined: 08/17/2007

Has there been any development in this area?

I am trying to add the ability to insert a value into the 'Text field' of a products Attribute when a user clicks a link for that product with the desired 'Text field' value appended to the URL

Right now I have it set up so that the user manually types in the value which they can read from the URL, then they click on the Add To Cart button to place their order.

Thanks in advance,

Lowell

Posts: 15
Joined: 08/17/2007

??? hook_add_to_cart ???

I was looking at this hook, it might work for my application.

The customer can click a link that simply adds the item to the cart with the attributes value set.

I will experiment with this alternate approach, any help or example will be appreciated.
For example, how to go about it so that the attribute is set when the item is added to the cart and the browser returns to their shopping page (or any other defined url) automatically.

Posts: 701
Joined: 11/05/2007
Bug FinderFAQ ModeratorGetting busy with the Ubercode.

If I understand what you're asking, I think Cart Links does what you want: http://www.ubercart.org/contrib/1427

--

<tr>.

Posts: 15
Joined: 08/17/2007

Cart Links will let me add a Product to the cart and give me a destination url option, but what I really need is to be able to submit the option text to the product as well, similar to the request to modify the price automatically.

I describe my situation:

Users can view over 100,000 photos in a third party app (Gallery attached to Drupal)
From the photo view, users can order prints (3x5, 4x6, 5x7, etc)
In Ubercart, I have products corresponding the the prints (3x5, 4x6, 5x7, etc)
I haven't really thought about somehow generating 100,000 Attribute Options for each print size.

So instead, I created one Attribute Option as a blank text field that the user can input the Image_Code which is readily available in the url as ?Image_Code=123456

I can do php and html but the programming logic is a bit over my head in these modules.
The simplest solution I can think of is to extract the Image_code from the url and insert it in the Attribute/Option text box.

Placing it directly in the cart Like the Cart Links can do would actually work better if it was designed to add the Image_Code to the product.

Posts: 3959
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Oh but it is... Smiling

If you make an attribute for the product w/ no options, you can still specify any option using the cart link if it's just going to be a number like this. And then of course you can still go right to the cart page.

You just need to know the attribute ID for the image code, which can be generated for you in a system message by turning on the cart links module, making sure in its settings that the first checkbox is checked, and then going to the product page and clicking the add to cart button. Go ahead and put a value in the textfield and submit to see what the path is going to be for a link w/ the image code filled in, too.

Posts: 15
Joined: 08/17/2007

Looks like it should work perfect, except...

Well I tried it and there seems to be a glitch of some kind.

here is an example cart link product action w/url:
http://my.domain/cart/add/p39_q1_o5a5_o4a

I enter this into a link (also directly in the address bar) and the system message reports only this:
p39_q1

These were simplified examples, the actual code, as reported by the system message when adding the product manually to the cart is this:
p39_q1_o5a5_o4aEventName_123456

please let me know what you think is happening here Smiling

Posts: 3959
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

Maybe try it without including the event name?

Posts: 15
Joined: 08/17/2007

same thing, as described above, I tried it with only the options tags

the system message by manually adding to cart seems to handle the text fine

Posts: 15
Joined: 08/17/2007

Hello again Ryan...

it's been six weeks and I am at it again, this time I figured out the error. You should be able to fix it in a snap.

The output on my screen when adding a product with options and attributes has the "o" and the "a" transposed. If you look at my examples above, the code uses an o#a# format which I got from the reported output.

When I use the a#o# format, it works pretty good. Smiling

It would be great if I could also use text, underscores, and dashes for the attribute options.

Please let me know if this is possible or even do-able. Maybe I could try myself if I have a clue where to look first.

Posts: 701
Joined: 11/05/2007
Bug FinderFAQ ModeratorGetting busy with the Ubercode.

Lowell wrote:

The output on my screen when adding a product with options and attributes has the "o" and the "a" transposed. If you look at my examples above, the code uses an o#a# format which I got from the reported output.

When I use the a#o# format, it works pretty good. Smiling

I seem to recall that bug was fixed many months ago - what version of Ubercart are you using?

Lowell wrote:

It would be great if I could also use text, underscores, and dashes for the attribute options.

Yes, it would. Maybe if Cart Links defined an escape character so those things could be embedded in the link...

--

<tr>.

Posts: 15
Joined: 08/17/2007

Thanks for the reply, I am using Ubercart 5.x-1.0-rc4

I also just retested and it still outputs the o#a# format even though the instructions on the cart links correctly describes the a#o# format.

(I am adding this option to my cart from a Gallery2 photo gallery module in a Drupal site, it works perfect...now I want to display the g2 image in my cart...any ideas appreciated)

thanks

Posts: 701
Joined: 11/05/2007
Bug FinderFAQ ModeratorGetting busy with the Ubercode.

Here's the old issue: http://www.ubercart.org/issue/2442/show_cart_link_attribute_not_formatte...

I reopened that thread so Ryan would see it.

--

<tr>.

Posts: 3959
Joined: 08/07/2007
AdministratorHead Code Monkey - I eat bugs.

As you may have guessed, the a#o# is the right way. However, on the Livetest and in the code, this is the way the message is being built. My hunch is you either have two copies of Ubercart laying around in your valid modules directories and need to get rid of one, or perhaps the upload failed for the cart links module before. Puzzled

Posts: 15
Joined: 08/17/2007

thanks a bunch...

I had a few uc_xxx modules in the root of the modules directory. Now those modules are working better as well.