我正在尝试使用主题套件在 Shopify 中自定义主题。
一切都很好,因为我注意到运行命令 theme 后deploy --allow-live,我丢失了 Shopify 上保存的自定义字段的所有值。
例如,这是我的文件“homepage.intro.liquid”的代码:
<div class="image">
<a class="banner-opacity" href="#"><img src="{{section.settings.intro_one_img | img_url: '470x570'}}"></a>
</div>
Run Code Online (Sandbox Code Playgroud)
这是架构的一部分:
{% schema %}
{
"name": "Homepage Intro",
"settings": [
{
"id": "intro_one_img",
"type": "image_picker",
"label": "Immagine 1"
},
...
{% endschema %}
Run Code Online (Sandbox Code Playgroud)
这就是我正在做的:
我进入 Shopify 管理员中的自定义主题,我可以毫无问题地上传和选择图像,并且一切正常。
之后,假设我需要向我的主题添加一个文件或文件夹,但它未正确上传到 Shopify 后台。
所以,我停止“主题手表”,然后跑步deploy --allow-live。
文件或文件夹已正确上传。
我在第 1) 点上传的图像不再被选中。
所有字段都会发生这种情况……不仅是图像,甚至文本字段。
我究竟做错了什么?提前致谢。
这是按钮的代码:
{% assign p_annual = all_products[section.settings.paid_product_annual] %}
{% assign p_free = all_products[section.settings.free_product] %}
{% if section.settings.productlink1label != blank %}
<button class="btn"
type="submit"
name="paid-plan"
id="paid-plan-option-annual"
data-variant-id="{{ p_annual.selected_or_first_available_variant.metafields.subscriptions.discount_variant_id }}"
data-variant-interval-value="{{ p_annual.metafields.subscriptions.shipping_interval_frequency }}"
data-variant-interval-unit="{{ p_annual.metafields.subscriptions.shipping_interval_unit_type }}"
data-quickadd-id="{{ p_annual.selected_or_first_available_variant.id }}"
data-quickadd-properties
>
{{ p_annual.selected_or_first_available_variant.price | money_without_trailing_zeros }}{{ section.settings.productlink1label }}
</button>
{% endif %}
Run Code Online (Sandbox Code Playgroud)
该代码通过 ID 获取项目并发出 AJAX 请求。
// quick add
_document.on('click', '[data-quickadd-id]', function() {
let _this = $(this);
loadingBarTrigger('start');
itemAdd(
_this.attr('data-quickadd-id'),
_this.attr('data-quickadd-properties'),
(_this.attr('data-quickadd-quantity'))
? _this.attr('data-quickadd-quantity')
: 1,
(!html.is('#cart')) ? true : false,
(html.is('#cart')) …Run Code Online (Sandbox Code Playgroud) 情况
我正在尝试调用Shopify REST API,其中有超过 50-250 个结果,但我无法从包含Pagination Links 的cURL Response 中获取链接标头。
Cursor-Pagination API 文档中的链接标头示例( https://shopify.dev/tutorials/make-paglated-requests-to-rest-admin-api )
#...
Link: "<https://{shop}.myshopify.com/admin/api/{version}/products.json?page_info={page_info}&limit={limit}>; rel={next}, <https://{shop}.myshopify.com/admin/api/{version}/products.json?page_info={page_info}&limit={limit}>; rel={previous}"
#...
Run Code Online (Sandbox Code Playgroud)
链接rel参数确实显示,但链接为空,如下所示。
我的 Shopify 通话功能
function shopify_call($token, $shop, $api_endpoint, $query = array(), $method = 'GET', $request_headers = array()) {
// Build URL
$url = "https://" . $shop . ".myshopify.com" . $api_endpoint;
if (!is_null($query) && in_array($method, array('GET', 'DELETE'))) $url = $url . "?" . http_build_query($query);
$headers = [];
// Configure cURL
$curl …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个已经有一些标签的数组。我想循环浏览购物车中的每个产品并将标签添加到数组中。{{tag }} 部分正在工作,但它没有被分配给数组。
{% assign finalTaglist = "apples, oranges, peaches" | split: ", " %}
{% for item in cart.items %}
<p>
{% for tag in item.product.tags %}
{{tag}}
{% assign finalTaglist = finalTaglist | concat: tag %}
{% endfor%}
</p>
{% endfor%}
<p>Final Tag List : {{finalTaglist}}</p>`
Run Code Online (Sandbox Code Playgroud)
`
我正在使用内置元字段的 shopify 并将其类型设置为 JSON,但不知何故循环该值不起作用。
{
"slides": [{
"title": "Title 1",
"description": "This is description body",
"image": "https://cdn.shopify.com/s/files/"
}, {
"title": "Title 2",
"description": "This is description body",
"image": "https://cdn.shopify.com/s/files/"
}]
}
Run Code Online (Sandbox Code Playgroud)
上面是我设置的示例值,下面是代码,但它根本不起作用。
{% if product.metafields.spec.slider != blank %}
<div class="grid">
{% assign sliders = product.metafields.spec.slider %}
{% for slider in sliders %}
<div class="grid__item">
<img src="{{ slides.image }}" alt="" />
<h4>{{ slides.title }}</h4>
<p>{{ slides.description }}</p>
</div>
{% endfor %}
</div>
{% endif %}
Run Code Online (Sandbox Code Playgroud) 下面是我的滑块代码,我遇到了无法读取空读取属性的错误,请添加,请做需要的
$('.main_images').slick({
slidesToShow: 1,
slidesToScroll: 1,
arrows: false,
asNavFor: '.thumb_images'
});
$('.thumb_images').slick({
slidesToShow: 4,
slidesToScroll: 1,
asNavFor: '.main_images',
dots: false,
focusOnSelect: true,
vertical: true,
arrows:false,
infinite: false,
responsive: [
{
breakpoint: 481,
settings: {
vertical: false,
infinite: true,
slidesToShow: 3,
slidesToScroll: 1
}
}
]
});
});
Run Code Online (Sandbox Code Playgroud) 如何在 Shopify Liquid 文件中获取当前访客国家/地区代码?
{{ localization.country.iso_code }}
我使用这段代码但不起作用。它始终获取商店位置国家/地区代码。
我正在尝试访问一个 javascript 文件,该文件是我的 Shopify 应用程序的一部分,并记录从我的后端 php 脚本返回的数据,但我收到一个 Ngrok 错误页面。我已将代理 url 添加到 Shopify 上的应用程序代理设置中,并按如下方式访问它:
$.ajax({
type: 'GET',
async: true,
datatype: JSON,
url: '/tools/app-script',
data: {
// search: search,
shop: window.location.href,
url: window.location.href
},
beforeSend: function() {
// function while sending...
},
success: function(result) {
console.log('SUCCESS');
// const data = JSON.parse(result);
console.log(result);
},
error: function(error) {
// Create function for errors in the page request.
console.log('ERROR');
console.log(error);
}
});
Run Code Online (Sandbox Code Playgroud)
在控制台中,我看到result请求成功后正在记录,但是,我没有得到我期望的数据。相反,我收到以下 Ngrok 消息:
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta …Run Code Online (Sandbox Code Playgroud) 我有一个具有多个自定义域的商店。我正在尝试查找当前正在请求的域名。
域:
somestore.myshopify.com
store.customdomain1.com
store.customdomain2.com
当请求进入store.customdomain1.com/collections时,有一个变量会告诉我它来自store.customdomain1.com吗?