All things Shopify and commerce
We need to update the variant title by REST API
I already coded for the updated Title in PHP but still have not updated it. The Code is running successfully.
That is PHP Code please give me Solution
$shopifyStore = SHOP . '.myshopify.com'; $apiKey = API_KEY; $password = PASSWORD; $apiKey = API_KEY; $password = PASSWORD; $shopUrl = $shopifyStore; $variantId = $QUR[0]['shopify_product_variant_id']; // Replace with the actual variant ID $newVariantTitle = base64_decode($QUR[0]['item_name']); // Replace with the desired new title $apiUrl = "https://$apiKey:$password@$shopUrl/admin/api/" . APIV; $variantData = [ 'variant' => [ 'id' => $variantId, 'title' => $newVariantTitle, ], ]; //pre($variantData); echo "$apiUrl/variants/$variantId.json"; $ch = curl_init("$apiUrl/variants/$variantId.json"); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($variantData)); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', ]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); if (curl_errno($ch)) { echo 'Error updating variant title: ' . curl_error($ch); } else { $responseData = json_decode($response, true); pre($responseData); }
By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024