Hi all,

I am struggling with the following. For ordering print jobs I need users to input an amount of pages in a text attribute field. The price should be updated accordingly.

For instance:
Ordering 10 copies of a printjob containing 40 pages would amount to:

Order quantity 10
40 pages per copy (40*0.05)
= 10*(40*0.05)

I use the attribute token module but I have no way of finding out what token is generated for the text attribute's input field. From firebug I can see it is called attribute-1 and I've labeled the attribute 'pages' but using $attribute-1 or [pages] yields no results.

I have tried figuring out what token is used though admin/help/token but I get no help available for the (installed and enabled) token module.

To make things worse, I have abosolutely no idea how to make the syntax for the example above.

Could anyone offer me an example or any help?

Comments

tr’s picture

Project: Ubercart Custom Price » Ubercart Attribute Tokens
Status: Active » Fixed

I'm going to move this to the queue for uc_attribute_tokens, because it's really about how to use that module.

The attribute token is the "Name" of the attribute.

Go to admin/store/attributes on your site and you should see a table of your attributes. The table columns are:
Name, Label, Required, List position, Number of options, Display type, Operations

You want to use the value in the "Name" column as the token name.

For example, with your situation, you probably have a textfield attribute with a name "Pages". (Note, capitalization does matter here ...).

So in the Custom Price Calculation for your product, you will want to write:

  $item->price = 0.05 * (int) [Pages];

The [Pages] token will get replaced by whatever number the user entered in the textfield, and the item price will be set accordingly.

alfthecat’s picture

Thanks TR! I hadn't solved it yet so I'm very grateful for your comprehensive explanation.

baff’s picture

Very helpful

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

m_mediacy’s picture

Status: Closed (fixed) » Active

Thanks for the help with attribute token, but how can i take the option of attribute?
cost, sell price, weight, for example something like this:
[Pages][sell_price]
but in this way i get 2 things: [Pages] attribute and the [sell_price] of product not the only attribute Pages sell price.

Someone can help me?

Thanks