[Liquid]capture
{%- capture 変数名 -%}dummy520x390.jpg{%- endcapture -%}
{%- capture html_params -%} data-product="{{ product.id }}" data-variant="{{ variant.id }}" style="{{ html_style }}"{%- endcapture -%}
{%- capture 変数名 -%}dummy520x390.jpg{%- endcapture -%}
{%- capture html_params -%} data-product="{{ product.id }}" data-variant="{{ variant.id }}" style="{{ html_style }}"{%- endcapture -%}
<a href="{{ product.url | within: collection }}"> <div class="image"><img src="{{ product.featured_image.src | img_url: 'large' }}" alt="{{ product.featured_image.alt | escape }}"></div> <h3>{{ product.title | escape }}</h3> {%- if product.metafields.my_fields.cf_text -%} <p>{{ product.metafields.my_fields.cf_text.value | escape }}</p> {%- else -%} <p>あいうえお</p> {%- endif -%} </a>
tax-text.liquid
{%- if shop.taxes_included -%}(税込){%- else -%}(税抜){%- endif -%}
管理画面「設定 > 税金」の「すべての価格を税込価格で表示する」チェックならばshop.taxes_includedはtrue
コレクションページネーション
{%- paginate collections[handle].products by collections[handle].all_products_count -%} {%- for product in collections[handle].products -%} //処理 {%- endfor -%} {%- endpaginate -%}
$result = DB::table('users')->insert([ ['email' => \DB::raw("AES_ENCRYPT('{$xxx}',SHA2('".env('DB_ENCRYPT_KEY')."',512))"), 'token' => \DB::raw("AES_ENCRYPT('{$yyy}',SHA2('".env('DB_ENCRYPT_KEY')."',512))")] ]);
{%- if shop.customer_accounts_enabled -%} {%- if customer -%} <a href="{{ routes.account_url }}">会員情報</a> <a href="{{ routes.account_logout_url }}">ログアウト</a> {%- else -%} <a href="{{ routes.account_register_url }}">会員登録</a> <a href="{{ routes.account_login_url }}">ログイン</a> {%- endif -%} {%- endif -%}
$record = DB::table('xxx') ->selectRaw("id,AES_DECRYPT(`yyy`,SHA2(:key1,512)) AS shop,AES_DECRYPT(`zzz`,SHA2(:key2,512)) AS token",['key1'=>env('DB_ENCRYPT_KEY'),'key2'=>env('DB_ENCRYPT_KEY')]) ->whereRaw("AES_DECRYPT(`yyy`,SHA2(:key,512)) = :yyy", ['key'=>env('DB_ENCRYPT_KEY'),'yyy'=>$yyy]) ->first();
all_productsは最大20件の商品情報しか保持しないため、コレクションを使用する必要がある。
予め全商品を含みコレクションハンドル「created-descending」のコレクションを作成しておく
function_get_product_by_handle.liquid
{%- assign get_product_by_handle = nil -%} {%- paginate collections['created-descending'].products by collections['created-descending'].all_products_count -%} {%- for model_product in collections['created-descending'].products -%} {%- if model_product.handle == target_handle -%} {%- assign product = model_product -%} {%- break -%} {%- endif -%} {%- endfor -%} {%- endpaginate -%}
define('DB_ENCRYPT_KEY','aabbccddeeff'); require_once __DIR__ . '/idiorm.php'; ORM::configure('mysql:host=localhost;dbname=xxxx'); ORM::configure('username', 'yyy'); ORM::configure('password', 'zzz'); ORM::configure('driver_options', [ PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', ]); $email = "xxxx@gmail.com"; ORM::configure('logging', true); try{ $orm = ORM::for_table('users')->select("id")->select_expr("AES_DECRYPT(`email`,'".DB_ENCRYPT_KEY."')","email")->select_expr("AES_DECRYPT(`name`,'".DB_ENCRYPT_KEY."')","name"); $orm->where_raw("AES_DECRYPT(`email`,?) = ?",array(DB_ENCRYPT_KEY,$email)); $record = $orm->find_one(); }catch (PDOException $e){ return null; } echo "<pre>"; var_dump(ORM::get_last_query()); echo "</pre>"; if(!empty($record)) { echo "<pre>"; echo $record->id; echo $record->email; echo $record->name; echo "</pre>"; }
function_get_variant_status.liquid
{%- comment -%}在庫チェック{%- endcomment -%} {%- assign is_in_stock = false -%} {%- if 0 < variant.inventory_quantity -%} {%- assign is_in_stock = true -%} {%- endif -%} {%- comment -%}在庫あり カートに入れる{%- endcomment -%} {%- if is_in_stock -%} {%- assign get_variant_status = 1 -%} {%- comment -%}在庫なし 「在庫切れの場合でも販売を続ける」がチェックされている カートに入れる{%- endcomment -%} {%- elsif is_in_stock == false and variant.inventory_policy == 'continue' -%} {%- assign get_variant_status = 2 -%} {%- comment -%}在庫なし 再入荷待ち{%- endcomment -%} {%- elsif is_in_stock == false and variant.incoming -%} {%- assign get_variant_status = 3 -%} {%- comment -%}在庫なし 完売しました{%- endcomment -%} {%- elsif is_in_stock == false -%} {%- assign get_variant_status = 4 -%} {%- comment -%}不明{%- endcomment -%} {%- else -%} {%- assign get_variant_status = 99 -%} {%- endif -%}