FROM CACHE - en_header

Shopify API Create Product is not creating product

andy_ellen
New Member
1 0 0
<?

	session_start();

	require __DIR__.'/vendor/autoload.php';
	use phpish\shopify;

	require __DIR__.'/conf.php';

	$shopify = shopify\client(SHOPIFY_SHOP, SHOPIFY_APP_API_KEY, SHOPIFY_APP_PASSWORD, true);

	try
	{
		# Making an API request can throw an exception
		$product = $shopify('POST /admin/products.json', array(), array
		(
			'product' => array
			(
				"title" => "Burton Custom Freestlye 151",
				"body_html" => "<strong>Good snowboard!</strong>",
				"vendor" => "Burton",
				"product_type" => "Snowboard",
				"variants" => array
				(
					array
					(
						"option1" => "First",
						"price" => "10.00",
						"sku" => 123,
					),
					array (
						"option1" => "Second",
						"price" => "20.00",
						"sku" => "123"
					)
				)
			)
		));

		print_r($product);
	}
	catch (shopify\ApiException $e)
	{
		# HTTP status code was >= 400 or response contained the key 'errors'
		echo $e;
		print_R($e->getRequest());
		print_R($e->getResponse());
	}
	catch (shopify\CurlException $e)
	{
		# cURL error
		echo $e;
		print_R($e->getRequest());
		print_R($e->getResponse());
	}

?>

It is working fine but I want to replace the normal text with my variable..

For example 

 

On clicking the button <button type="button">CLick me</button> 

<script type="text/javascript">
    $(document).ready(function(){
        $("button").click(function(){

           $.ajax({
                type: 'POST',
                dataType: 'json',
                url: '../create_product.php',
                success: function(data) {
                   console.log(data);
                   

                }
            });
   });
});
</script>

so You see there is button on click product,so it will work like this:

 

for

"title" => "Burton Custom Freestlye 151", it will be replaced with my product title

I have tried <?=product['title'] ?> but not working

Replies 0 (0)