Development discussions around Shopify APIs
<?
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
User | RANK |
---|---|
42 | |
16 | |
9 | |
9 | |
8 |
Thanks to all Community members that participated in our inaugural 2 week AMA on the new E...
By Jacqui Mar 10, 2023Upskill and stand out with the new Shopify Foundations Certification program
By SarahF_Shopify Mar 6, 2023One of the key components to running a successful online business is having clear and co...
By Ollie Mar 6, 2023