Jump to content

Nexus money JSON


InvisionHQ

Recommended Posts

I'm working to a bulk importer, I've a field that store Price(2):

title,desc,price
Hello world,This is an example,44

In the db table the price is stored as:

{"USD":{"amount":"44","currency":"USD"}}

I need to recreate manually this json using \IPS\nexus\Money object?

that with Simply json_encode give:

{"amount":"44","currency":"USD"}

I recreate the json with:

$item->price = '{"'.\IPS\nexus\Customer::loggedIn()->defaultCurrency().'":'.json_encode($price).'}';

But I suspect that there are a better way.

Link to comment
Share on other sites

array( 'USD' => array( 'amount' => 44, 'currency' => 'USD' ) );

This is the array format you need to get that JSON string.

 

Based on your code above I think you can simply do:

$item->price = json_encode( array( \IPS\nexus\Customer::loggedIn()->defaultCurrency() => $price ) );

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...