Ecommerce Shopify WordPress Discussion

How can I getting only the number id of the product in shopify using graphql and laravel app

This is my route, Route::get('/carts/{numericProductID}', 'App\Http\Controllers\ShopifyController@showProductDetails') ->name('showProductDetails'); This is the link to redirect to another page to show/fetch the details of the selected product. <a href="{{ route('showProductDetails', ['numericProductID' => $product['node']['id']]) }}">View Details</a>
try this use Shopify; use Illuminate\Http\Request; public function showProductDetails(Request $request, $numericProductID) { // Build your GraphQL query to fetch the product details $query = <<<GRAPHQL { product(id: $numericProductID) { id title # Add other fields you want to retrieve } } GRAPHQL; // Make the GraphQL request to Shopify $response = Shopify::graph($query); // Parse the response JSON $productData = json_decode($response->getBody(), true); // Extract the numeric product ID $numericID = $productData['data']['product']['id']; // You can now use $numericID in your view or return it as needed // For example, return a view with the product details return view('product_details', ['product' => $productData['data']['product']]); } in view file <a href="{{ route('showProductDetails', ['numericProductID' => $product['id']]) }}">View Details</a>

December 30, 2023

Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.