Re: 在庫切れの際の条件分岐について

フォーラム 使い方全般 在庫切れの際の条件分岐について Re: 在庫切れの際の条件分岐について

#63274
yoshi0012
参加者

nanbu様

アドバイスありがとうございます。

早速、アドバイス通りに実行しましたところ、

無事うまく表示されました。

本当にありがとうございます。

私は商品一覧ページのcategory.phpと詳細ページwc_item_single.phpの2ページに

hold表示の設定を施したかったのですが、

無事両ページ共にステータス番号を取得してくれました。

1点ものの商品を多く抱えている方には多少は参考になるかもしれませんのでコードも記載します。

価格の部分を<?php if( !usces_have_zaiko() ) : ?> を削除し、下記のように変更しました。

(こちらは商品詳細ページの記述になります。)

<?php global $usces;

$status = (int)$usces->itemsku; ?>

<?php if( 0 === $status ): ?>

<div class=”field_price”><?php usces_the_itemPriceCr(); ?></div>

<?php endif; ?>

<?php if( 1 === $status ): ?>

<div class=”field_price”><?php usces_the_itemPriceCr(); ?></div>

<?php endif; ?>

<?php if( 2 === $status ): ?>

<span class=”price”><div class=”field_price”><?php echo apply_filters(‘usces_filters_single_sku_zaiko_message’, __(‘Sold Out’, ‘Sold Out’)); ?></div></span>

<?php endif; ?>

<?php if( 3 === $status ): ?>

<span class=”price”><div class=”field_price”><?php echo apply_filters(‘usces_filters_single_sku_zaiko_message’, __(‘入荷待ち’, ‘入荷待ち’)); ?></div></span>

<?php endif; ?>

<?php if( 4 === $status ): ?>

<span class=”price”><div class=”field_price”><?php echo apply_filters(‘usces_filters_single_sku_zaiko_message’, __(‘HOLD’, ‘HOLD’)); ?></div></span>

<?php endif; ?>

サイトでは$statusのステータスを

0→在庫あり

1→在庫あり(入荷中)

2→売り切れ

3→入荷待ち

4→HOLD

という風に設定しており、全て私の希望する表示にすることが出来ました。

恐らく、もっとスマートな記述法があるかとは思いますが、とりあえず表示されているので良しとしています。

ありがとうございました。