skip to Main Content

I’m working with eBay API and for some stupid reason prices have to be in double format even if zero.

For example:
I have a price of value 100
I need to send it to eBay as 100.00 but it must NOT be a string.

No matter what I’ve tried I get float(100) and not 100.00

I’ve tried (double), (int), doubleval() without any success.

number_format is out of the question because output is a string.

I’ve spend way too much time trying to get this right.

Please help.

LE:
Value passed to eBay: [value] => 120
Returned error: You have entered invalid start price or Buy It Now price.

I’m using ebay-sdk-php and the type I’m supposed to pass is documented here

eBay required type to be passed

2

Answers


  1. try this

      $var  = (float) number_format(float(100),2)
    
    Login or Signup to reply.
  2. Formated number types don’t exist in PHP. They also wouldn’t make any sense without a specific context.

    But the SDK you use provides custom types for creating the XML you send to eBay. For price it should be:

    new TypesAmountType(['value' => 100]);
    

    If that doesn’t work, post the code that produces the error. I doubt anybody can help without it.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search