我知道这已经在 SO 上解决了很多次,但所有的答案大多都在“向服务器添加某个标头”的脉络中。在这种情况下,API (Shopify) 工作得很好,可以通过 curl 轻松访问。
我已经尝试过使用 Axios 库和 Fetch API。
referrer,mode以及referrerPolicy在提取选项。我不明白为什么这在 cURL 中可以很好地工作,但在 fetch() 中却不能。
这是我的代码的缩短版本:
const apiKey = 'mykey';
const apiPassword = 'mypass';
const apibase = 'https://my-shop-domain.myshopify.com/admin/';
const endpoint = 'locations.json';
var headers = new Headers({
"Authorization": "Basic " + btoa( apiKey + ':' + apiPassword ),
});
fetch( apibase + endpoint {
method: 'GET',
headers: headers,
mode: 'no-cors',
// …Run Code Online (Sandbox Code Playgroud) 我已将Shopify active_shipping gem集成到我的网站中,我正在尝试从我的UPS帐户获得协商费率(我可以获得常规费率).我找不到有关协商费率的任何文件.有人可以帮我从这里出去吗?我认为这行代码应该可以工作,但它不会产生任何错误或任何不同的运费.
response = carrier.find_rates(origin, destination, packages, {negotiated_rates: true})
Run Code Online (Sandbox Code Playgroud)
我在这里跑过这个链接,但仍然没有运气:
https://github.com/Shopify/active_shipping/blob/master/lib/active_shipping/carriers/ups.rb
使用Shopify API,有没有办法为您的商店创建促销?如果没有,有没有办法在Shopify中以编程方式创建促销?(没有使用CURL帖子给管理员)
也就是说,我可以使用管理员手动创建促销并导航到Promotions并单击Add a discount code链接.我希望能够以编程方式执行相同的操作,或者确切地知道这是不可能的.我没有在api列表中看到任何明显的方法,但似乎应该是一种API方法.
我有一个字段,我settings.html希望用户输入由两个换行符分隔的多个段落.我想将这个输入字符串拆分为一个字符串数组,每个字符串代表一个段落.
我想做这样的事情:
{% assign paragraphs = settings.intro | split: '\n' %}
{% for paragraph in paragraphs %}
<p>
{{ paragraph }}
</p>
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
我似乎无法弄清楚如何在Liquid中引用换行符.我该怎么做呢?有什么工作吗?
我希望向我正在构建的 Shopify 商店添加社交登录功能。(我正在使用专业计划。)
我探索了 Shopify 应用商店中的一些可用的社交登录应用程序。在仔细研究它们的实际工作原理后,我对它们所遵循的总体方案有了以下理解。
我的问题如下:
我试图了解这是否确实是唯一的方法,因为我强烈地感觉到这种方法根本不安全。因此我宁愿不使用这种方法;或者如果我必须这样做,那么我宁愿为此编写自己的(私人)应用程序,这样至少我可以控制保存敏感用户凭据的应用程序/数据库的安全性。
如果我能得到任何帮助/想法,我将不胜感激。
我目前正在使用Shopify购买按钮.
在大多数情况下,我只是复制并粘贴嵌入代码并没有太大变化.如果你一直向下滚动"toggle":{,你会注意到我做了iframe和sticky设置为false.
将产品添加到购物车时,会在主体中显示切换购物车的按钮. .shopify-buy-frame.shopify-buy-frame--toggle
它通常div在屏幕的中间右上角显示为固定,但由于我的粘性选项设置为false,因此它被放置在屏幕的底部body.
我希望能够分配一个父容器,这个切换按钮最终会进入.理想情况下,我想将它放在我的标题中,而不是在页面正文的底部生成它.
例如:
<body>
<header>
<div id="cart-toggle">
<!-- THIS IS WHERE I WANT IT TO APPEAR -->
</div>
<header>
<!-- THIS IS WHERE IT APPEARS -->
</body>
Run Code Online (Sandbox Code Playgroud)
如果我能弄清楚如何为我的移动导航区域生成第二个切换按钮,则可获得奖励积分.
我搜索了默认的竞争对手和开发人员部分的切换选项,似乎无法弄明白.
如果有人可以提供帮助,将不胜感激.
我的嵌入代码
<script type="text/javascript">
/*<![CDATA[*/
(function () {
var scriptURL = 'https://sdks.shopifycdn.com/buy-button/latest/buy-button-storefront.min.js';
if (window.ShopifyBuy){if(window.ShopifyBuy.UI){ShopifyBuyInit();}else{loadScript();}}else{loadScript();}f
function loadScript() {var script = document.createElement('script');script.async = true;script.src = scriptURL;(document.getElementsByTagName('head')[0] …Run Code Online (Sandbox Code Playgroud) 我是 graphQL 的新手,我必须检索所有产品。我一直在环顾四周,观看教程和阅读,人们似乎返回了他们想要的所有某种类型的数据,但我不能。例如,它会抛出一个错误,指出您必须提供第一个或最后一个,但我想要全部,否则它会说totalCount或count不存在。
\n {\n products {\n id\n title\n price\n \n }\n}\n\n// or get total count of products\n\n {\n products {\n totalCount\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n我基本上是在尝试做类似的事情。我知道我可能不会收到任何帮助,因为没有人可以访问我的 shopify admin api,但甚至可能是一个示例或我可以看到的任何内容。这是来自我的产品选项的 graphQL 查询根。\n产品列表。
\nProductConnection!\nfirst: Int\nReturns up to the first n elements from the list.\n\nafter: String\nReturns the elements that come after the specified cursor.\n\nlast: Int\nReturns up to the last n elements from the list.\n\nbefore: String\nReturns the elements that come before the specified cursor.\n\nreverse: Boolean = false\nReverse the order of the underlying list.\n\nsortKey: ProductSortKeys …Run Code Online (Sandbox Code Playgroud) 我打算在Shopify主题上工作,我想弄清楚如何在本地运行/编辑它.如果可能的话,我希望能够做到以下几点:
这是可能吗?
如何在Visual Studio中格式化.liquid(Shopify liquid)代码.通过设置语言作为HTML我可以做到但同时,我不能使用Shopify自动完成.当我切换到liquid.html然后我可以使用自动完成但我无法格式化代码.有没有什么办法可以在Visual Studio中使用另一种语言和格式代码作为另一种语言?
我试图用Shop API在Shopify上添加多张图片但是,我无法将2张图片上传到一个产品.目前只上传了一张图片.如何在Shopify API中添加1张以上的图片?
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"
path2 = "audi2.jpg"
new_product = shopify.Product()
new_product.title = "Audi pictures test "
new_product.body_html = "body of the page <br/><br/> test <br/> test"
variant = shopify.Variant({'price': 1.00, 'requires_shipping': False,'sku':'000007'})
new_product.variants = [variant]
image = shopify.Image()
image2 = shopify.Image()
with open(path, "rb") as f:
filename = path.split("/")[-1:][0]
filename2 = path2.split("/")[-1:][0]
encoded = f.read()
image.attach_image(encoded, filename=filename)
image2.attach_image(encoded, filename=filename2)
new_product.images = [image,image2]
new_product.save()
Run Code Online (Sandbox Code Playgroud)