Hiện thì đồng hồ đếm ngược thời gian giảm giá cho sản phẩm đơn. Phần này khá là quan trọng để khuyến khích khách mua hàng mà theme lại không hỗ trợ. Nên này mình chia sẽ luôn cho ai cần.
Đầu tiên cần chèn đoạn code sau vào file functions.php của Child Theme.
1 |
<span class="_2cuy _19ii _2vxa"><span class="_7xn"><span class="com">/* Dev by Woovn */</span></span> </span><span class="_2cuy _19ii _2vxa"><span class="pln">add_shortcode</span><span class="pun">(</span><span class="str">'woovn_sale_date'</span><span class="pun">,</span> <span class="str">'sale_price_dates_to'</span><span class="pun">);</span></span><span class="_2cuy _19ii _2vxa"><span class="kwd">function</span><span class="pln"> sale_price_dates_to</span><span class="pun">()</span> <span class="pun">{</span></span><span class="_2cuy _19ii _2vxa"><span class="pln"> ob_start</span><span class="pun">();</span></span><span class="_2cuy _19ii _2vxa"> <span class="kwd">global</span><span class="pln"> $product</span><span class="pun">;</span></span><span class="_2cuy _19ii _2vxa"><span class="pln"> $sales_price_to </span><span class="pun">=</span><span class="pln"> get_post_meta</span><span class="pun">(</span><span class="pln">$product</span><span class="pun">-></span><span class="pln">get_id</span><span class="pun">(),</span> <span class="str">'_sale_price_da</span><span class="text_exposed_show"><span class="str">tes_to'</span><span class="pun">,</span> <span class="kwd">true</span><span class="pun">);</span></span></span><span class="text_exposed_show"><span class="_2cuy _19ii _2vxa"> <span class="kwd">if</span><span class="pun">(</span><span class="pln">is_single</span><span class="pun">()</span> <span class="pun">&&</span><span class="pln"> $product</span><span class="pun">-></span><span class="pln">is_on_sale</span><span class="pun">()</span> <span class="pun">&&</span><span class="pln"> $sales_price_to </span><span class="pun">!=</span> <span class="str">""</span><span class="pun">)</span> <span class="pun">{</span></span><span class="_2cuy _19ii _2vxa"><span class="pln"> $sales_price_year_to </span><span class="pun">=</span><span class="pln"> date</span><span class="pun">(</span><span class="str">"Y"</span><span class="pun">,</span><span class="pln"> $sales_price_to</span><span class="pun">);</span></span><span class="_2cuy _19ii _2vxa"><span class="pln"> $sales_price_month_date_to </span><span class="pun">=</span><span class="pln"> date</span><span class="pun">(</span><span class="str">"n"</span><span class="pun">,</span><span class="pln"> $sales_price_to</span><span class="pun">);</span></span><span class="_2cuy _19ii _2vxa"><span class="pln"> $sales_price_day_date_to </span><span class="pun">=</span><span class="pln"> date</span><span class="pun">(</span><span class="str">"j"</span><span class="pun">,</span><span class="pln"> $sales_price_to</span><span class="pun">);</span></span><span class="_2cuy _19ii _2vxa"><span class="pln"> echo do_shortcode</span><span class="pun">(</span> <span class="str">'[ux_countdown size="177" year="'</span><span class="pun">.</span><span class="pln">$sales_price_year_to</span><span class="pun">.</span><span class="str">'" month="'</span><span class="pun">.</span><span class="pln">$sales_price_month_date_to</span><span class="pun">.</span><span class="str">'" day="'</span><span class="pun">.</span><span class="pln">$sales_price_day_date_to</span><span class="pun">.</span><span class="str">'" time="00:00" t_week="Tuần" t_day="Ngày" t_hour="Giờ" t_min="Phút" t_sec="Giây" t_week_p="Tuần" t_day_p="Ngày" t_hour_p="Giờ" t_min_p="Phút" t_sec_p="Giây"]'</span> <span class="pun">);</span></span><span class="_2cuy _19ii _2vxa"> <span class="pun">}</span> </span><span class="_2cuy _19ii _2vxa"> <span class="kwd">return</span><span class="pln"> ob_get_clean</span><span class="pun">();</span></span><span class="_2cuy _19ii _2vxa"><span class="pun">}</span></span></span> |
Sau đó chúng ta chỉ việc chèn shortcode sau vào Custom HTML trong Tùy biến ▸ WooCommerce ▸ Product Page
1 |
<span class="_2cuy _19ii _2vxa"><span class="pun">[</span><span class="pln">woovn_sale_date</span><span class="pun">]</span></span> |
Chúc các bạn thành công. ????????????
Nguồn copy
Bài viết mới:
- 10 phím tắt cực kỳ hữu ích cho người dùng Window
- [Sưu tầm] 20 nguyên tắc thiết kế giúp website của bạn thêm phần chuyên nghiệp
- Css thường dùng, cách tùy biến contact form 7
- Table responsive cho các thiết bị mobile table, thay thế table cho flatsome
- Count Up Number trên themes Flatsome như thế nào?