在 ROR 中使用 shopify 应用在 shopify 站点 header 添加一个按钮

add one button in shopify site header using shopify app in ROR

我需要通过 shopify 在 shopify 网站中的搜索图标后插入一个 按钮 app.Give 我有一些建议。

提前致谢。

希望您应该在 Shopify API 的帮助下 replace/overwrite 您商店主题中的 snippets/header.liquid 文件,如下所示:

在您的应用中,尝试在您的根函数中执行以下操作:

header = ShopifyAPI::Asset.find("sections/header.liquid")
header.value # returns the contents of the header.liquid

使用 rails 子更新您的 header.value!如:

#this will add the button at appropriate place instead `{% endif %}`
header.value.sub!("{% endif %}", "<button type='button'>Click Button</button> {% endif %}") 

#do save    
header.save

希望对您有所帮助!!