Skip to content

Instantly share code, notes, and snippets.

View kuleyu's full-sized avatar
🗯️
uo uo uo

kuleyu kuleyu

🗯️
uo uo uo
View GitHub Profile
@kuleyu
kuleyu / finishCustomization.js.liquid
Created May 18, 2022 17:30 — forked from git-willie/finishCustomization.js.liquid
Bundle products and add all to cart after customization
$(document).on('click', '#finish-customization', function(e){
e.preventDefault();
bundle_prefix = "{{ product.handle | replace: '-','_' }}";
bundle_id = Math.floor((Math.random() * 100000) + 1);
$('input[name="properties[Custom Product ID]"]').val(bundle_prefix+'_'+bundle_id);
$(this).find('span').html('Adding to Cart');
var $result = decodeURIComponent($('#AddToCartForm-{{ section.id }}').serialize());
$result = $result.split('&');
@kuleyu
kuleyu / saleMotivator.js
Created May 18, 2022 17:29 — forked from git-willie/saleMotivator.js
Dynamic sales motivator message
// Display motivator message
ShopifyAPI.saleMotivator = function(cart, cart_motivator_goal, motivator_msg_selector) {
var cart_subtotal = parseFloat(cart.total_price / 100).toFixed(2);
var cart_motivator_goal = cart_motivator_goal;
var cart_motivator_goal_remaining = parseFloat(cart_motivator_goal - cart_subtotal).toFixed(2);
var motivator_msg = motivator_msg_selector;
if (cart_subtotal == 0) {
motivator_msg.html('FREE SHIPPING ON ORDERS OVER $' + cart_motivator_goal);
} else {
if (cart_subtotal >= cart_motivator_goal) {
1. add snippet to cart.liquid file at the bottom of the file
{% include 'upsell-modal' %}
2. add css to theme.liquid in the header
{{ 'upsell-modal.scss' | asset_url | stylesheet_tag }}
@kuleyu
kuleyu / upsell-products.liquid
Created May 18, 2022 17:25 — forked from git-willie/upsell-products.liquid
Upsell products similar to Amazon's
{% assign current_product_handle = product.handle %}
{% assign upsell_product_col = 'col-xs-4' %}
{% assign sum = product.price %}
{% assign number_of_upsell_products = 0 %}
{% for upsell_product in upsell_collection.products limit: 4 %}
{% unless upsell_product.handle == current_product_handle %}
{% assign sum = sum | plus: upsell_product.price %}
{% endunless %}
{% assign number_of_upsell_products = forloop.index %}
{% endfor %}
@kuleyu
kuleyu / it-ebooks.md
Created March 15, 2021 01:36 — forked from baiwfg2/it-ebooks.md
Download ebooks as you want
@kuleyu
kuleyu / 浏览器差异化对 iconfont 的影响.md
Created May 24, 2018 02:29
浏览器差异化对C的影响

<a href="#home" class="none">Home</a>
<a href="#information" class="icon1 iconfont">Infor</a>

icon1 iconfont 通过伪元素 :before 应用了 iconfont 字体图形的样式类。

上面在没有 span 元素的情况下,各浏览器对 icon1 iconfont 样式的渲染在 a 中的实体方面产生了不一样的行为:

  • 高版本的 Chrome :“Home” 与 “Infor” 样式效果一致,都是本该有的字体;
@kuleyu
kuleyu / javascript 的 foreach如何返回序号.md
Created May 15, 2018 17:00
javascript 的 foreach如何返回序号

先来看一个例子

var Arr = [100, 200, 300, 400, 500]
function fn (arr) {
    arr.forEach(function(item, index, array){
        if(item == 300) {
            return index;
            console.log(index);
 }
@kuleyu
kuleyu / outline.md
Created April 17, 2018 05:57
CSS定义了圆角文本框,可是获得焦点时是方角,显得很难看问题

CSS定义了圆角文本框,可是获得焦点时是方角,显得很难看问题

解决办法: 添加样式规则 outline:none; 即可解决。

下面来了解一下 css 的 outline 属性:

CSS defines a special sort of element decoration called an outline. In practice, outlines
are often drawn just beyond the borders, though (as we’ll see) this is not the whole
@kuleyu
kuleyu / 表格元素样式问题.md
Created April 16, 2018 11:23
table、thead、tdody、tfoot、tr 、th、td 等表格元素样式问题

先来了解一下 border-collapse 属性,该属性只属于具有(或设置了) display:table | table-inline 属性的元素。如下:

proprity:             border-collapse
Values:           collapse | separate | inherit
Initial value:         separate
Applies to:       Elements with the display value table or table-inline
Inherited: Yes
Computed value:        As specified
Note:             In CSS2, the default was collapse.
@kuleyu
kuleyu / 统一表单元素样式.md
Last active April 14, 2018 18:33
统一表单元素样式

inputselecttextarea 元素虽然都是表单元素中的 内行块级元素(默认 display:inline-block;),但是它们的区别还是挺大的。不仅仅表现在 paddingborder-width等常见属性上,更表现在box-sizing 属性上。

  • 默认 box-sizing 属性区别:
    • input 元素的默认 box-sizing 属性表现为 content-box,即 W3C 标准盒模型;
    • selecttextarea 元素的默认 box-sizing 属性表现为 border-box,即 IE(怪异)盒模型;

注:在 Chrome 的开发者工具里面各元素的默认 box-sizing 属性只在其值为 box-sizing 时才显示出来;没显示出来的,其值都默认为 content-box

select {
	appearance:none;