Закрыт

Svelte error : 'product' is not a store with a subscribe method with shopify api

<script>

import { getProduct } from '../lib/store';

const productId = 'a';

const product = getProduct(productId);

$: [login to view URL]($product);

let quantity = 0;

let price = 0;

let total = 0;

$: quantity = quantity < 1 ? 1 : quantity;

$: options = $[login to view URL]((items) => {

let list = {};

[login to view URL] = [login to view URL];

[login to view URL] = [login to view URL][0].value;

[login to view URL] = [login to view URL][1].value;

[login to view URL] = [login to view URL];

return list;

});

$: [login to view URL](options);

let selected_color;

let selected_size;

let selected;

$: selected = [login to view URL](function (elem) {

return [login to view URL] === selected_size && [login to view URL] === selected_color;

});

$: if (selected_color && selected_size) {

total = (quantity * selected[0].price).toFixed(2);

}

$: if (selected_color && selected_size) {

[login to view URL]('selected variant ID : ' + selected[0].id);

//alert('selected variant ID : '+ selected[0].id)

}

</script>

{#await product}

<h1>

{$[login to view URL]}

</h1>

<img

src={$[login to view URL][0].[login to view URL]}

alt="product"

style="width:350px;border-radius:15%;"

/>

<br /><br />

<h3>Color</h3>

{#each $[login to view URL][0].values as option}

<label>

<input bind:group={selected_color} selected="fa" type="radio" name={option} value={option} />

{option}

</label>

{/each}

<h3>Size</h3>

{#each $[login to view URL][1].values as option}

<label>

<input bind:group={selected_size} selected="fa" type="radio" name={option} value={option} />

{option}

</label>

{/each}

{#if selected_color}{selected_color} / {/if}

{#if selected_size}{selected_size}{/if}

<br /><br />

<label for="quantity">Quantity</label>

<input name="quantity" bind:value={quantity} style="width:150px;" type="number" />

<p>

price : $ {total}

</p>

{#if selected_color && selected_size}

<p>

Selected variant ID {selected[0].id}

</p>

{/if}

{/await}

This is my API function [login to view URL]

export async function getProduct(handle) {

const query = `

{

productByHandle(handle: "${handle}") {

collections(first: 1) {

edges {

node {

products(first: 5) {

edges {

node {

priceRange {

minVariantPrice {

amount

}

}

handle

title

description

id

images(first: 5) {

edges {

node {

originalSrc

altText

}

}

}

}

}

}

}

}

}

id

title

handle

description

images(first: 5) {

edges {

node {

originalSrc

altText

}

}

}

options {

name

values

id

}

variants(first: 25) {

edges {

node {

selectedOptions {

name

value

}

}

}

}

}

}`;

const response = await ShopifyData(query);

const product = [login to view URL] ? [login to view URL] : [];

return product;

}

Навыки: Svelte, Shopify Development

О клиенте:
( 0 отзыв(-а, -ов) ) Phuket, Thailand

ID проекта: #32620458

2 фрилансеров(-а) готовы выполнить эту работу в среднем за $15/час

sku5551ed6fd9643

Hi I have gone through the job description. I am a senior web and app developer having more than 5 years of experience in the field of development. I can develop and design the project for you as per your requirements Больше

$15 USD / час
(1 отзыв)
1.8
bassam10014

Hello, you need to import writeable from svelte/store and assign that to product. I will be happy to help you in anything else too. Regards, Bassam

$15 USD / час
(0 отзывов(-а))
0.0