InvisionHQ Posted June 3, 2018 Posted June 3, 2018 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.
teraßyte Posted June 3, 2018 Posted June 3, 2018 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 ) );
Recommended Posts
Archived
This topic is now archived and is closed to further replies.