WordPressのショッピングカートプラグイン「Welcart」。
既存テーマにも後からショッピングカート機能を追加できるので重宝している方も多いと思います。
Welcartは1つの商品でもSKU毎に価格が違ったりします。
Welcartの標準テンプレートだと先頭のSKU価格しか商品一覧画面で表示されないため、複数のSKUを持つ商品の場合は工夫が必要になります。
<?php
if(in_category('item')) :
$skus = get_post_meta($post->ID,'_isku_');
if(count($skus) > 1) :
usces_the_item();
while(usces_have_skus()) :
?>
<dl>
<dt><?php usces_the_itemSkuDisp(); ?></dt>
<dd><span><?php usces_the_itemPriceCr(); ?></span><?php usces_guid_tax(); ?></dd>
<?php if(!usces_have_zaiko()) : ?>
<dd class="soldout"><span><?php _e('Sold Out','usces'); ?></span></dd>
<?php endif; ?>
</dl>
<?php endwhile; else : ?>
<div class="price"><?php usces_crform( usces_the_firstPrice('return'),true,false); usces_guid_tax(); ?></div>
<?php if(!usces_have_zaiko_anyone()) : ?>
<div class="soldout"><?php _e('Sold Out','usces'); ?></div>
<?php endif; endif; ?>
<?php endif; ?>
参考
| usces_the_itemCode() | 商品コード | |
|---|---|---|
| usces_the_itemName() | 商品名 | |
| usces_the_itemSku() | SKUコード | |
| usces_the_itemSkuDisp() | SKU名 | |
| usces_the_itemCprice() | 定価 | |
| usces_the_itemPrice() | 売価 | |
| usces_the_itemZaiko() | 在庫状態 | |
| usces_the_itemSkuUnit() | 単位 | |
| usces_the_firstSku() | 先頭のSKUコード | |
| usces_the_firstPrice() | 先頭の売価 | |
| usces_the_firstCprice() | 先頭の定価 | |
| usces_the_firstZaiko() | 先頭の在庫状態 | |
| usces_the_lastSku() | 最後尾のSKUコード | |
| usces_the_lastPrice() | 最後尾の売価 | |
| usces_the_lastZaiko() | 最後尾の在庫状態 | |
| usces_the_itemQuant() | 数量入力フィールド | |
| usces_the_itemSkuButton($value) | カート投入ボタン | value はボタンの表示ラベル |
| usces_the_itemImage($number, $width, $height) | 商品画像出力タグ | number は画像のインデックス、0がメイン画像でそれ以降はサブ画像 width は画像の幅、heignht は画像の高さ(縦横比はWordpressに準ずる) |
| usces_the_itemImageURL($number) | 商品画像URL | number は画像のインデックス |
| usces_guid_tax() | 消費税ガイド | 「(税込)、(税別)」の表示 |
| usces_is_item() | 商品か否か | true 商品、false 商品以外 |
| usces_the_item() | オブジェクト準備 | |
| usces_sku_num() | SKUの数 | その商品が所有するSKUの数 |
| usces_is_skus() | SKUがあるか否か | true 存在する、false 存在しない |
| usces_have_skus() | ループ用フラグ | |
| usces_is_gptekiyo( $post_id, $sku, $quant ) | 業務パック割引適用フラグ | 業務パックが適用されるか否か |
| usces_the_itemGpExp( ) | 業務パック割引ガイド | |
| usces_get_itemSubImageNums() | 商品サブ画像の数 | |
| usces_is_options() | 商品オプションフラグ | true オプションあり、false 無し |
| usces_have_options() | ループ用フラグ | |
| usces_the_itemOptName() | 商品オプション名 | |
| usces_the_itemOption($name) | 商品オプションフィールド | |
| usces_is_cart() | カートフラグ | カーとの中に商品が、 true 存在する、false 存在しない |
| usces_the_company_name() | ショップの会社名 | |
| usces_the_zip_code() | ショップの郵便番号 | |
| usces_the_address1() | ショップの住所1 | |
| usces_the_address2() | ショップの住所2 | |
| usces_the_tel_number() | ショップの電話番号 | |
| usces_the_fax_number() | ショップのFAX番号 | |
| usces_the_inquiry_mail() | 問合せ用メールアドレス | |
| usces_the_postage_privilege() | 送料無料条件 | 送料が無料になる金額 |
| usces_the_start_point() | 初回ポイント | 会員入会したときのサービスポイント |
| usces_the_calendar() | 営業日カレンダー | |
| usces_loginout() | ログインリンク | |
| usces_is_login() | ログインフラグ | true ログイン中、false ログインしていない |
| usces_the_member_name() | ログインしている会員名 | |
| usces_is_membersystem_state() | 会員システムフラグ | true 会員制オン、false オフ |
| usces_is_membersystem_point() | ポイントシステムフラグ | true ポイント制オン、false オフ |
| usces_copyright() | コピーライト | |
| usces_totalprice_in_cart() | カート内の合計金額 | 商品のみの合計金額 |
| usces_totalquantity_in_cart() | カート内の合計数量 | 全数量 |
