#DieserLoki

1 messages ยท Page 1 of 1 (latest)

white axleBOT
sterile coral
#

Can you try changing that topmost layer to square brackets? It sounds like we are expecting an array but curly bracket notation makes it a hash

    "shipping_rate_data": {
      "display_name": "Standard Shipping",
      "type": "fixed_amount",
      "fixed_amount": {
        "amount": "695",
        "currency": "EUR"
      }
    }
  ],```
ancient fox
#

In my Code it is actually

        return [
            'shipping_rate_data' => [
                'display_name' => 'Standard Versand',
                'type' => 'fixed_amount',
                'fixed_amount' => [
                    'amount' => (int)round($product->getShipping()->getAmount() * 100),
                    'currency' => $product->getShipping()->getCurrency(),
                ]
            ]
        ]
sterile coral
#

Gotcha, checking in to the syntax here

sterile coral
#

Apologies I am still having trouble looking up this syntax. It does look like that is passing an array there

ancient fox
dreamy oracle
#

Hi there ๐Ÿ‘‹ taking a look, please bear with me a moment.

#

I'm thinking this might be happening because that field is expect an array of hashes, but it's being provided a single hash (looks like that is an array in your code). If you double up the outer square brackets you're using, does that resolve the error?

Something like this:

            'shipping_rate_data' => [
                'display_name' => 'Standard Versand',
                'type' => 'fixed_amount',
                'fixed_amount' => [
                    'amount' => (int)round($product->getShipping()->getAmount() * 100),
                    'currency' => $product->getShipping()->getCurrency(),
                ]
            ]
        ]]```
ancient fox
#

๐Ÿคฆโ€โ™‚๏ธ Thank you, that was actually it

dreamy oracle
#

Sweet, happy to help.