视频加载失败

Shopify 产品页面品牌风点击一键复制折扣码卡片分享

1234 字
6 分钟
Shopify 产品页面品牌风点击一键复制折扣码卡片分享
Shopify 产品页面品牌风点击一键复制折扣码卡片分享

点击一键复制折扣码是很多 Shopify 店铺都需要的热门实用功能。关于折扣码复制相关的教程,之前我发布过 Shopify 产品页多个折扣码一键复制功能。

增强版 Shopify主题 中也已经自带了折扣码复制功能,而本期将要分享的教程算是一个补充,不论你使用增强版主题还是其他主题,都可以跟随教程添加使用。

效果预览#

电脑端#

折扣码一键复制电脑端效果
折扣码一键复制电脑端效果

手机端#

折扣码一键复制手机端效果
折扣码一键复制手机端效果

因为很多 Shopify 个人卖家或者中小公司很难既具备设计资源有具备技术资源(个人卖家难以既懂设计又懂技术,而很多小公司只有设计师没有前端员工),所以我分享这类教程给大家使用。

以前制作一项功能需要自己首先学到比较熟练的程度才能做出效果,或者花钱付费请人做。而现在只需要提供一张截图,然后根据你自己的需求进行优化。

也就是先从你的同行品牌网站上截取功能效果,通过 ScreenShot to Code 识别截图获得基本的网页代码,再通过 AI 代码编辑器通过自然语言沟通进行优化,比如让它添加点击按钮时的折扣码复制功能,调整背景色和字号、字重等等。

哪怕你们公司有前端工程师,提一项需求可能也得排期和等待,现在你自己都能搞定:

直接使用#

💡

新手提示:折扣码在 Shopify 店铺后台 ~ 折扣 (Discount)中创建。

创建 Snippet 保存代码,并在产品模板中直接使用 [code] {% render ‘copy-coupon’ %} [/code]

复制

💡

如果产品信息模块 ~ 媒体文件宽度设置为 “大”,可能导致右侧宽度不够,改成 “中” 即可

先创建文件: [code] copy-coupon [/code]

复制 [code]

.coupon {
background-color: #222;
color: white;
display: flex;
border-radius: 10px;
position: relative;
overflow: hidden;
}
.coupon::before,
.coupon::after {
content: "";
position: absolute;
width: 20px;
height: 20px;
background-color: #f5f5f5;
border-radius: 50%;
}
.coupon::before {
top: 50%;
left: -10px;
transform: translateY(-50%);
}
.coupon::after {
top: 50%;
right: -10px;
transform: translateY(-50%);
}
.coupon-left {
flex: 1;
padding: 30px 40px;
display: flex;
flex-direction: column;
justify-content: center;
}
.coupon-right {
flex: 1;
padding: 20px;
display: flex;
justify-content: space-between;
align-items: center;
position: relative;
}
.coupon-right::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 1px;
height: 100%;
background-color: rgba(255, 255, 255, 0.3);
border-left: 1px dashed white;
}
.discount {
font-size: 4rem;
font-weight: bold;
line-height: 1;
margin: 0;
}
.off {
font-size: 2rem;
font-weight: bold;
margin-left: 5px;
}
.limited {
font-size: 1rem;
margin-top: 5px;
}
.code {
font-size: 1.2rem;
font-weight: bold;
white-space: nowrap;
}
.copy-btn {
background-color: #f6dd51;
color: #222;
border: none;
border-radius: 30px;
padding: 10px 20px;
font-size: 1rem;
font-weight: bold;
cursor: pointer;
text-transform: uppercase;
white-space: nowrap;
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.copy-btn:hover {
background-color: #f0cc5f;
transform: scale(1.15);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.copy-btn.copied {
background-color: #90EE90;
transform: scale(0.92);
box-shadow: none;
}
@media (max-width: 600px) {
.coupon {
flex-direction: column;
}
.coupon::before,
.coupon::after {
width: 15px;
height: 15px;
}
.coupon::before {
top: -7.5px;
left: 50%;
transform: translateX(-50%);
}
.coupon::after {
bottom: -7.5px;
left: 50%;
top: auto;
transform: translateX(-50%);
}
.coupon-right::before {
width: 100%;
height: 1px;
top: 0;
left: 0;
border-left: none;
border-top: 1px dashed white;
}
.coupon-left,
.coupon-right {
padding: 15px;
}
.discount {
font-size: 3rem;
}
.off {
font-size: 1.5rem;
}
.limited {
font-size: 0.9rem;
}
.code {
font-size: 0.9rem;
}
.copy-btn {
padding: 8px 15px;
font-size: 0.9rem;
}
}
</style>
<div class="coupon-container">
<div class="coupon">
<div class="coupon-left">
<div>
<span class="discount">20%</span>
<span class="off">OFF</span>
</div>
</div>
<div class="coupon-right">
<div>
<span style="font-size: 1.2rem;font-weight: bold;">Code:</span>
<span class="code">Bilibili</span>
</div>
<button class="copy-btn">COPY</button>
</div>
</div>
</div>
<script>
document.querySelector('.copy-btn').addEventListener('click', function () {
const codeElement = document.querySelector('.code');
const code = codeElement.textContent;
navigator.clipboard.writeText(code)
.then(() => {
this.textContent = 'COPIED';
this.classList.add('copied');
setTimeout(() => {
this.textContent = 'COPY';
this.classList.remove('copied');
}, 2000);
})
.catch(err => {
console.error('复制失败:', err);
});
});
</script>

[/code]

复制

批量添加和多组折扣#

通过产品标签控制显示#

你可能想要针对某些产品设置,所以我将演示通过产品系列筛选并添加 Tags 的方式来对特定的产品进行显示:

代码: [code] {% if product.tags contains ‘discount20’%} {% render ‘copy-coupon’ %} {% endif %} [/code]

复制

在少数商品上展示折扣#

如果你只想在某一款或者某几款商品上使用折扣,也可以用这种方式,商品比较少的话,Tag 直接在对应的产品编辑界面右侧添加即可。

多组折扣码#

或者如果你想添加多组折扣(不够优雅但对新手友好,易于理解): [code] {% if product.tags contains ‘discount20’%} {% render ‘copy-coupon-20’ %} {% elsif product.tags contains ‘discount15’ %} {% render ‘copy-coupon-15’ %} {% endif %} [/code]

复制

样式优化#

  • 如果你想对这个功能进行个性优化,例如调整背景色等
  • 或者修改 Shopify 网站上的其他内容样式,可以参考这个教程:

支持与分享

如果这篇文章对你有帮助,欢迎分享给更多人或打赏支持!

打赏
Shopify 产品页面品牌风点击一键复制折扣码卡片分享
https://welcome4535.de5.net/posts/shopify/
作者
码境科技
发布于
2025-11-20
许可协议
CC BY-NC-SA 4.0
相关文章智能推荐
1
分享几个全球卖的最火的shopify模板
Shopify教程Shopify破解独立站模板,我们在用的,代码安全 安装方法: 主题商店-上传ZIP 1、Ella https://preview.themeforest.net/item/ella-multipurpose-shopify-theme-os-20/full_screen_pre
2
如何在一分钟内找到 100+ 同行独立站?
Shopify教程Myip.ms 是集全球浏览器、主机信息、网站和 IP 数据库的一个信息查询网站。具体操作: 1.打开 https://myip.ms ,可以输入 myshopify.com 2.拉到第一个表格中,点击「View All Records »」 回复可见内容 3.在 Full/Pa
3
告别繁琐!AI 智能工具,助你快速打造 Shopify 高转化落地页
Shopify教程什么是落地页?(Landing Page)? 落地页是一个独立的网页,专门为特定的营销或广告活动而创建。也是你希望用户到达的一个页面。 为什么要使用落地页? 提高转化率 : 这是落地页最核心的优势。 获取高质量线索: 落地页通常包含表单,用于收集潜在客户的信息(如姓名、邮箱、电话
4
诊断独立站打开速度的 3 个工具
Shopify教程大家应该都遇到过这种情况:广告 CTR 不错,但落地页跳出率特别高。很多时候不是素材问题,是网站太慢。 今天就分享几个独立站性能的实测方法,大家可以检查一下你们的独立站访问性能到底如何~ 一、应该以多快速度加载? 根据 skilled.co,47% 的客户希望网页在 2 秒或更短
5
Shopify EDM 邮件营销神器 Klaviyo 最新免费系列教程
Shopify教程BFCM 将至,请了一个专门做邮件营销的朋友,来给大家重新录制 Shopify EDM 系列免费教程。一共分为 5 期内容,已更新完成。 点击这里立即注册 Klaviyo ,并跟随本系列教程操作。 往期相关教程 第 146 期 跨境电商 Shopify 独立站黑五网一大促如何准备
随机文章随机推荐

评论区

Profile Image of the Author
码境科技
Hello, I'm 码境科技。
公告
这里是码境科技的博客,分享建站、玩机与 AI 折腾。
分类
标签
最新动态
站点统计
文章
327
分类
44
标签
47
总字数
839,103
运行时长
0 天
最后活动
0 天前
站点信息
构建平台
Vercel
博客版本
Firefly v6.16.9
文章许可
CC BY-NC-SA 4.0
文章目录