这是我的表单,它工作正常,但现在我想要AJAX它.
<%= form_tag variant_path(variant.id), :method => :put, :class => 'update_inv_form' do %>
<%= text_field_tag :inventory_quantity, variant.inventory_quantity %>
<%= submit_tag 'Update' %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
当我添加了:遥控=> true属性的形式通过AJAX成功提交(我可以看到它发生在服务器上,我可以看到的变化,当我刷新页面).我想正确更新视图以显示更改而不刷新页面.这是我的更新操作:(请注意,我在这里不使用ActiveRecord模型.)
def update
variant = ShopifyAPI::Variant.find(params[:id])
variant.inventory_quantity = params[:inventory_quantity]
variant.save
redirect_to root_path
end
Run Code Online (Sandbox Code Playgroud)
更新
感谢您帮助我解决这个问题的答案结果解决方案正如他所说,但是我遇到了一个小问题.我想要更新的视图生活在app/views/home/index.html.erb ,我正在处理这个:Variants #update.(变种控制器,更新动作)
我把我的update.js.html放在我的视图所在的同一目录中:app/views/home我的服务器抛出了500错误:缺少模板.事实证明,我必须创建一个app/views/variants/目录并将update.js.html文件放在那里.问题解决了.
我正在尝试使用 Shopify 的 python API 来检索产品图像列表,但出现错误。我认为这是因为网址格式错误。有解决这个问题的方法吗?
images = shopify.Image.find(product.id)
Run Code Online (Sandbox Code Playgroud)
错误堆栈跟踪:
Traceback:
File "/home/rodxavierbondoc/.virtualenvs/shopify/src/django/django/core/handlers/base.py" in get_response
105. response = middleware_method(request, callback, callback_args, callback_kwargs)
File "/home/rodxavierbondoc/.virtualenvs/shopify/local/lib/python2.7/site-packages/mezzanine/pages/middleware.py" in process_view
45. return view_func(request, *view_args, **view_kwargs)
File "/home/rodxavierbondoc/.virtualenvs/shopify/src/django/django/views/generic/base.py" in view
48. return self.dispatch(request, *args, **kwargs)
File "/home/rodxavierbondoc/.virtualenvs/shopify/src/django/django/utils/decorators.py" in _wrapper
25. return bound_func(*args, **kwargs)
File "/home/rodxavierbondoc/.virtualenvs/shopify/src/django/django/contrib/auth/decorators.py" in _wrapped_view
20. return view_func(request, *args, **kwargs)
File "/home/rodxavierbondoc/.virtualenvs/shopify/src/django/django/utils/decorators.py" in bound_func
21. return func(self, *args2, **kwargs2)
File "/home/rodxavierbondoc/.virtualenvs/shopify/src/django/django/utils/decorators.py" in _wrapper
25. return bound_func(*args, **kwargs)
File "/home/rodxavierbondoc/workspace/sg/djangoproject/shopify_app/decorators.py" in wrapper
10. return …Run Code Online (Sandbox Code Playgroud) 我的问题是,当试图在Shopify中插入某种背景图像时,它从不显示任何内容.
我有一个导航栏,其中有一个客户想要的模式,当我尝试启用它时,再也没有任何反应.
我在css背景线上使用的代码(来自google搜索)是
background:url( "{{'navBggreen.jpg' | asset_url }}")
Run Code Online (Sandbox Code Playgroud)
我也试过了
background:url( {{'navBggreen.jpg' | asset_url }} )
Run Code Online (Sandbox Code Playgroud)
没别的了.Shopify的教程或任何类型的文档非常缺乏,所以......
无论如何,有谁知道如何使这个工作?
我已添加了Shopify文档中描述的基本联系表单.
我的代码:
{% form 'contact' %}
{% if form.posted_successfully? %}
<div class="successForm feedback">
<p>Thanks for contacting us. We'll get back to you as soon as possible.</p>
</div>
{% endif %}
{% if form.errors %}
<div class="errorForm feedback">
<p>Sorry, we were unable to submit your inquiry because it contained {{ form.errors | size | pluralize: 'an error', 'a few errors' }}.<br/>Please correct the following and submit again:</p>
{% for field in form.errors %}
<p><strong>The {{ field | capitalize | …Run Code Online (Sandbox Code Playgroud) 如果我一次只做一个现有产品,我可以发布一些元数据:
/admin/products/#{id}/metafields.json
{ "metafield":
{
"namespace":"c_f",
"key":"label",
"value":"Am:pm",
"value_type":"string"
}
}
Run Code Online (Sandbox Code Playgroud)
当我尝试在同一帖子中添加多个字段时,我收到一个错误:
{ "metafields":[
{
"namespace":"c_f",
"key":"artist",
"value":"CHEMICAL BROTHERS",
"value_type":"string"
},
{
"namespace":"c_f",
"key":"label",
"value":"Virgin",
"value_type":"string"
}
]
}
Run Code Online (Sandbox Code Playgroud)
错误是:
"metafield": "Required parameter missing or invalid"
Run Code Online (Sandbox Code Playgroud)
API仅包含一个元数据的示例.有没有什么方法可以将metafields(需要大约8个)组合成一个POST请求?
我一直在尝试访问Shopify网站的客户登录页面.但它总是将我重定向到商店主页.对于其他客户相关页面,它也会发生同样的事情.我不明白为什么会这样.这是我的商店网址.
https://baseonesolutions-jwellery-demo.myshopify.com/account/login/
任何帮助将不胜感激.提前致谢
Liquid 新手在这里寻求帮助。我有两个系列和每个系列中的一个产品,它们具有相似的名称:
(集合) 零食棒 > (产品)巧克力片
(集合)蛋白棒 > (产品)薄荷巧克力片
我正在尝试根据集合和产品句柄隐藏/显示特定于这些项目(在同一页面内)的内容。我已经尝试了以下方法,但是即使 == 应该是特定的,这也显示了这两个项目,它不是并且显示为它认为 Chocolate-chip 和 chocholate-chip-mint 是匹配的,但它不是:
{% if product.handle == "chocolate-chip" %} // do something {% endif %}
Run Code Online (Sandbox Code Playgroud)
我试过这个,但不行:
{% if collection == "protein-bars" && product.handle == "mint-chocolate-chip" %} // do something {% endif %}
Run Code Online (Sandbox Code Playgroud)
我也试过这个,但它不起作用:
{% if product.handle == "mint-chocolate-chip" | within: collections.protein-bars %} // do something {% endif %}
Run Code Online (Sandbox Code Playgroud)
最终,我只想验证我是否在产品页面上,我的逻辑检查:
https://www.blakesesedbased.com/collections/snack-bars/products/chocolate-chip
https://www.blakesesedbased.com/collections/protein-bars/products/mint-chocolate-chip
您可以在 Mint Chocolate Chip 页面上看到逻辑认为“chocolate-chip”是产品匹配,并且在 mint-chocolate-chip 页面上显示了关于 Chocolate-chip 的信息(在产品显示下方的白色部分)。
我对if else语句有疑问。我有一个按2个不同标签排序的集合:材质和尺寸。当没有选择材料,材料和尺寸时,我希望显示标题和段落。您可以在这里查看收藏:https : //www.sengefabriksudsalg.dk/collections/madrasser/
我已经试过了:
{% if pageValues contains 'Latexmadrasser' %}
<h2 class="mat-h2-collecion">Latexmadrasser</h2>
<p> Hello </p>
{% elsif pageValues contains 'Latexmadrasser' and '70x200' %}
<h2 class="mat-h2-collecion">Latexmadrasser 70x200</h2>
<p> Hello </p>
{% endif %}
Run Code Online (Sandbox Code Playgroud)
但是它只打印第一条语句:(
我试图按照这里的链接在我的 Windows 10 系统上安装 shopify-cli:https ://shopify.github.io/shopify-app-cli/getting-started/install/#rubygem-all-platforms
我通过巧克力安装了 Ruby:
choco install ruby
Run Code Online (Sandbox Code Playgroud)
然后我下载了 rubygems 的压缩版本并通过命令运行安装程序:
ruby setup.rb
Run Code Online (Sandbox Code Playgroud)
然后我尝试通过命令安装 shopify 应用 CLI:
gem install shopify-cli
Run Code Online (Sandbox Code Playgroud)
我最终遇到错误,错误要求我安装 MSYS2 https://www.msys2.org/,我这样做了。
然后我再次尝试安装 shopify-cli 但现在遇到了这个错误:
PS C:\WINDOWS\system32> gem install shopify-cli
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
ERROR: Error installing shopify-cli:
ERROR: Failed to build gem native extension.
current directory: C:/tools/ruby27/lib/ruby/gems/2.7.0/gems/shopify-cli-1.3.1/ext/shopify-cli
C:/tools/ruby27/bin/ruby.exe -I C:/tools/ruby27/lib/ruby/site_ruby/2.7.0 -r ./siteconf20201009-14664-r6pzlb.rb extconf.rb
current directory: C:/tools/ruby27/lib/ruby/gems/2.7.0/gems/shopify-cli-1.3.1/ext/shopify-cli
make "DESTDIR=" clean
current directory: C:/tools/ruby27/lib/ruby/gems/2.7.0/gems/shopify-cli-1.3.1/ext/shopify-cli
make "DESTDIR=" …Run Code Online (Sandbox Code Playgroud) 在 Shopify 中,似乎有 2 个区域可以上传站点图像:文件(设置 -> 文件)和资产(主题编辑器 -> 资产文件夹)。这里有什么区别,为什么要将图像放在一个之上?
shopify ×10
liquid ×3
conditional ×1
contact-form ×1
e-commerce ×1
form-data ×1
form-fields ×1
jquery ×1
ruby ×1
rubygems ×1
shopify-api ×1
shopify-app ×1