All things Shopify and commerce
Hi,
I am trying to create a two step registration process.
Step 1 - Normal customer registration which accepts Firstname, email and password.
Step 2 - Custom registration form to get the address and company details.
For step 2 , a custom form will be created then on submit, it will make a ajax call which updates the details against the particular customer in DB.
Now, I have all my address fields are updated but the country alone is not updated.
Can anyone suggest me why this would be ?
sample json code structure for customer
{ "id": 7532313805142, "email": "jamestest@gmail.com", "accepts_marketing": true, "created_at": "2023-12-28T17:50:33+01:00", "updated_at": "2023-12-28T17:51:26+01:00", "first_name": "James", "last_name": "Harry", "orders_count": 0, "state": "enabled", "total_spent": "0.00", "last_order_id": null, "note": null, "verified_email": false, "multipass_identifier": null, "tax_exempt": true, "tags": "BE 12345", "last_order_name": null, "currency": "EUR", "phone": null, "addresses": [ { "id": 9986085585238, "customer_id": 7532313805142, "first_name": "James", "last_name": "Harry", "company": "ABC Corp", "address1": "123 Main Street", "address2": "Apartment 456", "city": "Bruges", "province": null, "country": "Belgium", "zip": "1234", "phone": "123-456-7890", "name": "James Harry", "province_code": null, "country_code": "BE", "country_name": "Belgium", "default": true } ], "accepts_marketing_updated_at": "2023-12-28T17:50:33+01:00", "marketing_opt_in_level": "single_opt_in", "tax_exemptions": [], "email_marketing_consent": { "state": "subscribed", "opt_in_level": "single_opt_in", "consent_updated_at": "2023-12-28T17:50:33+01:00" }, "sms_marketing_consent": null, "admin_graphql_api_id": "gid://shopify/Customer/7532313805142", "default_address": { "id": 9986085585238, "customer_id": 7532313805142, "first_name": "James", "last_name": "Harry", "company": "ABC Corp", "address1": "123 Main Street", "address2": "Apartment 456", "city": "Bruges", "province": null, "country": "Belgium", "zip": "1234", "phone": "123-456-7890", "name": "James Harry", "province_code": null, "country_code": "BE", "country_name": "Belgium", "default": true } }
Here in my frontend request I am sending country as France but still this is not updated.
address.php?address1=123 Main Street&address2=Appartment 123&city=Bruges&country=France&company=ABCCorp&zip=12345&phone=123546&tags=BE+1234567&customerId=7532313805142
Sample php code
$customer_address1 = $_GET['address1']; $customer_address2 = $_GET['address2']; $customer_city = $_GET['city']; $customer_country = $_GET['country']; $customer_company = $_GET['company']; $customer_phone = $_GET['phone']; $customer_zip =$_GET['zip']; $customer_tags =$_GET['tags']; $data = json_decode($response, true) // Check if the customer is found if (isset($data['customer'])) { $selectedCustomer = $data['customer']; // Update the address, country, and company fields $selectedCustomer['addresses'][0]['address1'] = $customer_address1; $selectedCustomer['addresses'][0]['address2'] = $customer_address2; $selectedCustomer['addresses'][0]['city'] = $customer_city; $selectedCustomer['addresses'][0]['country'] = $customer_country; $selectedCustomer['addresses'][0]['company'] = $customer_company; $selectedCustomer['addresses'][0]['phone'] = $customer_phone; $selectedCustomer['addresses'][0]['zip'] = $customer_zip; $selectedCustomer['tags'] = $customer_tags; $updateUrl = "https://$api_key:$password@$shop_url/admin/api/2023-10/customers/{$selectedCustomer['id']}.json"; $options = [ 'http' => [ 'method' => 'PUT', 'header' => 'Content-Type: application/json', 'content' => json_encode(['customer' => $selectedCustomer]), ], ]; $context = stream_context_create($options); $updateResponse = file_get_contents($updateUrl, false, $context);
Can I know why my country is not updated ?
In Canada, payment processors, like those that provide payment processing services t...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025