我正在为客户在 Shopify 中开发一个带有布鲁克林主题的项目。我们的客户仅展示三种产品,每种产品有 4 个变体。根据要求,我们不必在购物车页面上重定向,只需在添加变体后单击产品页面上的按钮即可重定向到结账页面。
为此,我用谷歌搜索找到正确的解决方案,但找不到正确的解决方案。所以我用 jquery 编写了这个过程,它正在工作。但我所做的过程是一种令人讨厌的方式,我想要一些干净的过程。我知道有一个应用程序,但我的客户不打算为其购买任何应用程序。
我编写的脚本是:
在product-template.liquid文件中,我注释掉了“添加到购物车”按钮,而是添加了一个按钮。
<button name="checkoutty" class="btn to">Checkout</button>
Run Code Online (Sandbox Code Playgroud)
以及该液体模板中的脚本:
$(function() {
$(window).on('load',function(){
$.ajax({
type: "POST",
url: '/cart/clear.js',
success: function(){
//alert('I cleared the cart!');
},
dataType: 'json'
});
})
});
$(document).ready(function(){
$('.single-option-selector__radio').click(function(){
if($(this).is(':checked')){
$('.product-single__add-to-cart button[type="submit"]').removeClass('disabled').attr('disabled','');
$('button[type="submit"]').attr('disabled','');
}
});
$('.to').click(function(){
$('[action="/cart/add"]').trigger('submit')
});
});
Run Code Online (Sandbox Code Playgroud)
并在cart.liquid模板中
<script>
$(window).load(function(){
$('.cart__checkout').trigger('click');
});
</script>
Run Code Online (Sandbox Code Playgroud)
虽然它正在工作,但我对此并不满意,因为它重定向到购物车页面,然后重定向到结帐页面,因为我强制提交购物车添加表单,然后在购物车液体页面上结帐 btn 单击事件。
在购物车页面上,我可能有额外的预加载器来隐藏内容。所以这一切都是令人讨厌的过程。任何人都可以指导我进行任何更简单和干净的过程吗?
提前致谢。
我正在尝试通过 Python Shopify API 添加新产品。我知道如何添加标题、正文和图片,但我在添加价格时遇到问题,我需要 'requires_shipping': False。我在任何地方都找不到如何实现这一目标。
这是我到目前为止所拥有的。
import shopify
API_KEY = 'dsfsdsdsdsdsad'
PASSWORD = 'sadsdasdasdas'
shop_url = "https://%s:%s@teststore.myshopify.com/admin" % (API_KEY, PASSWORD)
shopify.ShopifyResource.set_site(shop_url)
path = "audi.jpg"
new_product = shopify.Product()
new_product.title = "Audi pictures test "
new_product.body_html = "body of the page <br/><br/> test <br/> test"
###########this part is so far good. but the bottom part is not working####
variant = shopify.Variant(price=9.99)) # this does not work
new_product.variant() # this does not work
variant_2 = shopify.Variant(requires_shipping=False) #this does not work
new_product.variant_2() …Run Code Online (Sandbox Code Playgroud) 我正在研究 Shopify 主题。我想从一些简单的页面中删除 /pages。我没有从 Shopify 支持或论坛或谷歌找到任何解决方案。我该如何解决?
当我提到范围 read_all_orders 时。我在安装时遇到以下错误
Oauth 错误missing_shopify_permission:read_all_orders
没有 read_all_orders 范围应用程序安装完美。
我不知道到底发生了什么,我正在尝试新创建的商店和 2 个月老的商店
我的范围:-“read_products”、“read_orders”、“read_customers”、“write_orders”、“read_price_rules”、“write_price_rules”、“read_all_orders”
我想对我工作中的一家小型批发店使用批发价格比较。
尽管如此,我在下面插入购物车的代码工作正常,但在计算总价格比较时没有考虑每件商品的数量。现在我看到的是每件商品收集的价格比较,但没有乘以数量。
有人可以帮我吗?
非常感谢,埃利亚斯
{% assign total_cart_item_price = 0 %}
{% assign total_cart_compare_price = 0 %}
{% for item in cart.items %}
{% assign total_cart_item_price = total_cart_item_price | plus: item.price %}
{% assign total_cart_compare_price = total_cart_compare_price | plus: item.variant.compare_at_price %}
{% endfor %}
<h1>Total price to be invoiced {{total_cart_compare_price | plus: item.variant.compare_at_price | money }}</h1>
<h1>Total price to be paid up front {{total_cart_item_price | money}}</h1>
Run Code Online (Sandbox Code Playgroud) 我的商店中有一个产品页面。我的所有产品都有关联的供应商。对于每个供应商,我都有一个自定义 Shopify 页面,并且在此页面上附加了几个元字段。元字段包括供应商(公司)国家/地区、成立年份等内容......
在我的产品页面上,我想显示有关供应商的上述信息。如果我在自定义供应商页面上,我可以使用以下内容访问供应商的元字段:
{% assign vendor_country = page.metafields.mynamespace.country %}
Run Code Online (Sandbox Code Playgroud)
如果我在产品页面上,是否可以获得相同的元字段信息?在这种情况下,默认情况下 Liquid 变量的上下文page将不正确。我需要一种方法来根据product.vendor变量设置此上下文,然后请求自定义供应商页面数据。
我可以使用以下代码调用产品图像的 URL
{{ product | img_url: "medium" }}
Run Code Online (Sandbox Code Playgroud)
这个输出:
//cdn.shopify.com/s/files/1/0087/0462/products/shirt14_medium.jpeg?v=1309278311
Run Code Online (Sandbox Code Playgroud)
<img>然而,当我在这样的标签中使用这种液体代码时
<img src="{{ product | img_url: "medium" }}" />
Run Code Online (Sandbox Code Playgroud)
输出是:
<img src="" />
Run Code Online (Sandbox Code Playgroud)
如何正确展示产品图片?
我在 Shopify API 上使用 Graphql,并且还需要在查询中使用变量。我找到了这篇文章,但它不起作用,因为我正在使用这些查询变量。
这就是我收到的确切错误:
SyntaxError (/home/fc-gui/app/controllers/concerns/product_graphql.rb:26: dynamic constant assignment
FIRST_PRODUCTS = CLIENT.parse <<-'GRAPHQL'
Run Code Online (Sandbox Code Playgroud)
然后这是我尝试运行查询的方法
def run_first_query
FIRST_PRODUCTS = CLIENT.parse <<-'GRAPHQL'
query($first: Int){
products(first: $first) {
pageInfo {
hasNextPage
}
edges {
cursor
node {
id
title
featuredImage {
originalSrc
}
}
}
}
}
GRAPHQL
first = { "first": number_of_products_to_return}
@query_result = CLIENT.query(FIRST_PRODUCTS, variables: first)
get_last_cursor
end
Run Code Online (Sandbox Code Playgroud)
我尝试创建类似于上述帖子的客户端,例如这两个选项,但没有运气:
CLIENT = ShopifyAPI::GraphQL.new
##
def graphql_client
ShopifyAPI::GraphQL.new
end
Run Code Online (Sandbox Code Playgroud)
任何人都能够在 Ruby 中使用变量运行 graphql 查询并且不会出现此错误?
我正在寻找一个液体运算符,用于判断字符串是否仅包含指定的字符串(即完全匹配)。
例如,假设我的产品有两个标签,“黑色”和“黑白”,而我只想触发“黑色”的事件,我将如何处理?下面的液体会触发两者,从而输出两次消息。
{% if tag contains 'Black' %} Hi {% endif %}
Run Code Online (Sandbox Code Playgroud)
我试过例如
{% if tag = 'Black' %} Hi {% endif %}
Run Code Online (Sandbox Code Playgroud)
但这会出现错误并且似乎不允许。是否有一个运算符可以精确匹配字符串?