php-shopify
php-shopify copied to clipboard
Address->set() causes API error "address_ids - expected Hash to be a Array"
Calling the following code causes the API to return the error address_ids - expected Hash to be a Array (where $address_ids is an associative array of address IDs):
$shopify->Customer($id)->Address->set(['address_ids' => $address_ids, 'operation' => 'destroy']);
This is because http_build_query is including the numeric indexes in the query string (e.g. address_ids[0]=123&address_ids[1]=456). The API is expecting address_ids[]=123&address_ids[]=456.
A possible (if slightly ugly) fix would be to add the following line to CustomerAddress.php after the $url has been generated:
$url = preg_replace('/(address_ids%5B)\d+(%5D)/', '$1$2', $url);