22 replies [Last post]
darek's picture
Offline
Joined: 08/18/2008
Juice: 5
Was this information Helpful?

Hi,

I'm trying to integrate ubercart with an affiliate system and have run into a problem. The [order-total] token has a dollar sign at the beginning of the numbers, something I need to remove.

I'm new to php, but this is what I tried:

<?php
$amount
= "[order-total]";
$amount = substr($amount, 1);
?>

...which unfortunately gives me:

order-total]

But if I don't use substr and do echo $amount it give me the dollar amount like $2.50

Is there any way I can remove the dollar sign from the beginning of the value in [order-total]?

Thanks.

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Remove $ from [order-total] token

I assume you're talking about in an invoice file or something? You could just use $order->order_total directly.

Insurrectus's picture
Offline
Spreading the word - Ubercart for president.
Joined: 08/22/2007
Juice: 364
Same question

I'm trying to populate an affiliate tracking code in the successful order confirmation at admin/store/settings/checkout/edit/messages

I've set my input format to PHP.

I'm using the following code:

<img src="https://shareasale.com/sale.cfm?amount=<?php $order->order_total ?>&tracking=[order-id]&transtype=sale&merchantID=xxxx" width="1" height="1">

It exports as:

https://shareasale.com/sale.cfm?amount=&tracking=4182&transtype=sale&merchantID=xxxx

Notice the missing amount? What am I missing?

Insurrectus's picture
Offline
Spreading the word - Ubercart for president.
Joined: 08/22/2007
Juice: 364
Re: Same question

Any ideas?

torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4110
Re: Re: Same question

Yeah it needs to be

<?php
print $order->order_total;
?>

.. You're missing the method "print". (You could also use "echo".)

--
Help directly fund development: Donate via PayPal!

Insurrectus's picture
Offline
Spreading the word - Ubercart for president.
Joined: 08/22/2007
Juice: 364
Re: Re: Re: Same question

Thanks, but...it didn't work.

My code:

<img src="https://shareasale.com/sale.cfm?amount=<?php print $order->order_total; ?>&tracking=[order-id]&transtype=sale&merchantID=xxxx" width="1" height="1">

My output:

https://shareasale.com/sale.cfm?amount=&tracking=4199&transtype=sale&merchantID=xxxx

I also tried:

<img src="https://shareasale.com/sale.cfm?amount=<?php echo $order->order_total; ?>&tracking=[order-id]&transtype=sale&merchantID=xxxx" width="1" height="1">

No dice. Any ideas?

torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4110
Re: Re: Re: Re: Same question

Hmm weird, it should work. Have you tried just using [order-total] with something other than PHP? Try Filtered HTML? That's what we use for our checkout message and it works fine... never actually used PHP for it, but I don't imagine that would destroy the order tokens.

--
Help directly fund development: Donate via PayPal!

Insurrectus's picture
Offline
Spreading the word - Ubercart for president.
Joined: 08/22/2007
Juice: 364
Re: Re: Re: Re: Re: Same question

[order-total] works just fine to export the total but it has the "$" with it. I need it without the dollar symbol.

torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4110
Re: Re: Re: Re: Re: Re: Same question

Interesting... you might try doing a drupal_set_message(print_r($order,true)); in that Message field, just to see if you are getting the whole $order object. I can't imagine what would be causing it not to work. Sorry =/

Also, could you tell us what version of UC you're on?

--
Help directly fund development: Donate via PayPal!

Insurrectus's picture
Offline
Spreading the word - Ubercart for president.
Joined: 08/22/2007
Juice: 364
Re: Re: Re: Re: Re: Re: Re: Same question

Tried that but nothing was printed to screen:

https://shareasale.com/sale.cfm?amount=&tracking=4206&transtype=sale&merchantID=xxx

U1.3

Insurrectus's picture
Offline
Spreading the word - Ubercart for president.
Joined: 08/22/2007
Juice: 364
Re: Re: Re: Re: Re: Re: Re: Re: Same question

Ryan/Lyle - any ideas?

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Re: Re: Re: Re: Re: Re: Re: Re: Same question

If nothing printed to the screen, something's wrong or the order object just isn't loaded yet. What if you loaded the order object using the $_SESSION['cart_order'] variable first?

Insurrectus's picture
Offline
Spreading the word - Ubercart for president.
Joined: 08/22/2007
Juice: 364
Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Same question

Ryan, I'm not really a coder, how would I do that?

Insurrectus's picture
Offline
Spreading the word - Ubercart for president.
Joined: 08/22/2007
Juice: 364
I've tried this: <img

I've tried this:

<img src="https://shareasale.com/sale.cfm?amount=<?php global $_SESSION['cart_order']; echo $order->order_total; ?>&tracking=[order-id]&transtype=sale&merchantID=21337" width="1" height="1">

And get an invalid character error witht he "]"

Any ideas?

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: I've tried this: <img

That session variable is simply an order ID, so you have to load the order first. Try something like...

<?php
  $order
= uc_order_load($_SESSION['cart_order']);
  print
uc_currency_format($order->order_total, FALSE);
?>
Insurrectus's picture
Offline
Spreading the word - Ubercart for president.
Joined: 08/22/2007
Juice: 364
Thanks Ryan That Worked

I used this code:

<img src="https://shareasale.com/sale.cfm?amount=<?php $order = uc_order_load($_SESSION['cart_order']); print uc_currency_format($order->order_total, FALSE); ?>&tracking=[order-id]&transtype=sale&merchantID=xxxxx" width="1" height="1">

Result:

https://shareasale.com/sale.cfm?amount=0.00&tracking=4266&transtype=sale&merchantID=xxxxx

Thanks Ryan, it works great!

Insurrectus's picture
Offline
Spreading the word - Ubercart for president.
Joined: 08/22/2007
Juice: 364
Verified

I just verified with Shareasale.

Thanks again Ryan and Torgos.

delmont's picture
Offline
Joined: 04/10/2009
Juice: 14
Just to verify

So you put this code:

<img src="https://shareasale.com/sale.cfm?amount=<?php $order = uc_order_load($_SESSION['cart_order']); print uc_currency_format($order->order_total, FALSE); ?>&tracking=[order-id]&transtype=sale&merchantID=xxxxx" width="1" height="1">

On this page:
admin/store/settings/checkout/edit/messages

In these text boxes:
Checkout completion message header
Checkout completion message body
Checkout completion for logged in users
Checkout completion for existing users
Checkout completion for new users

With the filter settings set to PHP.

Is that correct?

Thanks to all contributors of this page for their help on this.

torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4110
Re: Just to verify

@Delmont, that looks correct to me. Glad you got it working, Insurrectus.

--
Help directly fund development: Donate via PayPal!

delmont's picture
Offline
Joined: 04/10/2009
Juice: 14
Thanks!

Works perfectly!

delmont's picture
Offline
Joined: 04/10/2009
Juice: 14
Working?

Insurrectus: did you ever get this to work? I'm doing the exact same thing with Share-A-Sale, but can't convert that amount token to a string, which is the way to go, I think.

scrambled's picture
Offline
Joined: 10/31/2008
Juice: 42
worked but adds tax

Hi,

I just signed up for shareasale and this works great, but.... it is also adding the taxes to the commission rate. What can I put in to give the total with out taxes?

So you put this code:

<img src="https://shareasale.com/sale.cfm?amount=<?php $order = uc_order_load($_SESSION['cart_order']); print uc_currency_format($order->order_total, FALSE); ?>&tracking=[order-id]&transtype=sale&merchantID=xxxxx" width="1" height="1">
On this page:
admin/store/settings/checkout/edit/messages

In these text boxes:
Checkout completion message header
Checkout completion message body
Checkout completion for logged in users
Checkout completion for existing users
Checkout completion for new users

With the filter settings set to PHP.

amalgamotion's picture
Offline
Joined: 09/15/2011
Juice: 13
Re: worked but adds tax

How do you set the filter settings for these fields in 7.x-3.0?