• プラグイン一覧
    - WCEX Item Combo Set
    - WCEX Amazon Pay
    - WCEX Wishlist お気に入りリスト
  • リリース情報
  • お役立ちコラム
  • お問い合わせ
  • サポート
    • よくある質問
      • WCEX Amazon Pay
      • WCEX Wishlist お気に入りリスト
      • wcex-item-combo-set
    • リファレンス
      • WCEX Amazon Pay
      • WCEX Wishlist お気に入りリスト
      • wcex-item-combo-set
新規会員登録
ログイン
新規会員登録
ログイン
カート
  • プラグイン一覧
    • - WCEX Item Combo Set
    • - WCEX Amazon Pay
    • - WCEX Wishlist お気に入りリスト
  • リリース情報
  • お役立ちコラム
  • サポート
    • - よくある質問
      • - WCEX Amazon Pay
      • - WCEX Wishlist お気に入りリスト
      • - wcex-item-combo-set
    • - リファレンス
      • - WCEX Amazon Pay
      • - WCEX Wishlist お気に入りリスト
      • - wcex-item-combo-set
  • お問い合わせ
Aivec APPs > WCEX Wishlist お気に入りリスト > 関数 > CRUD::buildWishlistRow
レファレンス
バージョン
3.1.6
絞り込み:
目的から探す
お気に入りデータを取得 お気に入りページのHTMLを取得 スナックバーアラート

目次

  • パラメータ
  • 戻り値
  • ソース
  • 関連アイテム
    • 使用するアイテム
    • 使用されるアイテム

フック

  • アクション
  • フィルター

ファンクション

  • データ取得
  • ユーティリティー
  • 条件判断
  • 表示系

関数

CRUD::buildWishlistRow( array $item )

お気に入りリストの一商品にメタデータを追加し、返す


パラメータ #パラメータ

$item

(配列) (必須) CRUD::getWishlistItems() を参照


戻り値 #戻り値

Top ↑

(配列)お気に入りリストの商品のすべてのデータのキー・バリュー配列
  • 'id'
    (数値)お気に入りリスト商品の主キーID
  • 'serial'
    (文字列)シリアル化された商品データ。Welcartのカート商品シリアルと同じ形式。
  • 'postId'
    (数値)商品投稿ID
  • 'sku'
    (文字列)商品SKU
  • 'price'
    (数値)現在の商品価格
  • 'quantity'
    (数値)商品の数量。デフォルト値は1
  • 'advance'
    (文字列)商品のカスタムデータ
  • 'options'
    (配列)商品オプションの配列
  • 'optstrs'
    (配列)key:valueフォームの商品オプション文字列の配列
  • 'optmap'
    (配列)キー・バリュー商品オプションの配列
  • 'itemDeleted'
    (bool)商品が削除されればtrue、そうでなければfalse
  • 'itemPermalink'
    (文字列)商品ページへのURL
  • 'cartThumbnailSrc'
    (文字列)商品サムネイル画像URL
  • 'isgptekiyo'
    (bool)商品の業務パックの申し込みがあった場合はtrue、そうでなければfalse
  • 'inCart'
    (bool)すでにカートに入っていればtrue、そうでなければfalse
  • 'itemCode'
    (文字列)Welcart商品コード
  • 'itemName'
    (文字列)Welcart商品名
  • 'cartItemName'
    (文字列)カート/お気に入りリストページでの表示のためフォーマットした商品名
  • 'cartItemNameParts'
    (配列)フォーマットされた商品名のそれぞれの部分
  • 'itemRestriction'
    (文字列)Welcart商品制限(適用された場合)
  • 'formattedPrice'
    (文字列)ユーザーに表示されるローカライズされた価格
  • 'inStock'
    (bool)商品の在庫があればtrue、なければfalse
  • 'skuZaikonum'
    (数値)Welcart在庫数
  • 'stockid'
    (数値)Welcart在庫ID
  • 'stock'
    (文字列)Welcart在庫で表示されるテキスト(つまり「在庫あり」)
  • 'optionsAreValid'
    (bool)商品オプションが有効である場合はtrue、そうでなければfalse
  • 'cartButtonClass'
    (文字列)「カートに追加する」ボタンのCSS class
  • 'cartButtonText'
    (文字列)「カートに追加する」ボタンの表示テキスト
  • 'icon'
    (文字列)表示するアイコンの名前。利用可能なアイコンの詳しくはこちら:https://fomantic-ui.com/elements/icon.html
  • 'deleteButtonClass'
    (文字列)削除ボタンのCSS class
  • 'unitPriceLabel'
    (文字列)単価ラベルの表示テキスト
  • 'stockStatusLabel'
    (文字列)在庫状況ラベルの表示テキスト
  • 'toItemPageButtonText'
    (文字列)「商品ページへ」ボタンの表示テキスト
  • 'deleteButtonText'
    (文字列)削除ボタンのテキスト
  • 'changedOptsText'
    (文字列)商品オプションの再選択が必要な場合の表示テキスト
  • 'deletedInfoText'
    (文字列)商品が削除された場合の表示テキスト

ソース #ソース

Top ↑

ファイル: src/API/CRUD.php

    public static function buildWishlistRow(array $item) {
        global $usces, $wpdb;

        $row = [];
        $array = unserialize($item['item_serial']);
        $ids = array_keys($array);
        $skus = array_keys($array[$ids[0]]);
        $row['id'] = isset($item['id']) ? (int)$item['id'] : 0;
        $row['serial'] = $item['item_serial'];
        $row['postId'] = (int)$ids[0];
        $row['sku'] = $skus[0];
        $priceWhenAdded = $item['price'];

        $post_id = (int)$row['postId'];
        $sku = $row['sku'];
        $unit_price = null;
        $tempcart = new \usces_cart();

        /*
         * `get_realprice` uses `$this->serial` internally so we need to set `serial`
         * before calling it.
         *
         * We can't use `$usces->cart->get_realprice(...)` because spoofing `serial`
         * would directly affect the cart session.
         */
        $tempcart->serial = $item['item_serial'];

        // `$sku` is automatically urldecoded in `get_realprice`
        $row['price'] = (int)$tempcart->get_realprice($post_id, $sku, 1, null, $unit_price);

        $row['quantity'] = isset($item['quantity']) && (int)$item['quantity'] > 0 ? (int)$item['quantity'] : 1;
        $row['advance'] = isset($item['advance']) ? $item['advance'] : '';
        $options = $array[$ids[0]][$skus[0]];
        $opt_fields = usces_get_opts($post_id, 'sort');
        $new_opt = [];
        foreach ($opt_fields as $key => $field) {
            $name = urlencode($field['name']);
            $new_opt[$name] = isset($options[$name]) ? $options[$name] : '';
        }
        /**
         * Filters the item options array
         *
         * @param array  $options
         * @param int    $post_id Item post ID
         * @param string $sku
         * @param string $serial Serialized Welcart item
         */
        $row['options'] = apply_filters(
            'wcexwl_filter_key_unserialize_options',
            $new_opt,
            (int)$ids[0],
            $skus[0],
            $item['item_serial']
        );
        $optstrs = [];
        $optmap = [];
        if (is_array($options) && count($options) > 0) {
            foreach ($options as $key => $value) {
                $optstr = '';
                if (!empty($key)) {
                    $key = urldecode($key);
                    if (is_array($value)) {
                        $c = '';
                        $optstr = esc_html($key) . ' : ';
                        $optval = '';
                        foreach ($value as $v) {
                            $optval .= $c . nl2br(esc_html(urldecode($v)));
                            $c = ', ';
                        }
                        $optstr .= $optval;
                        $optmap[esc_html($key)] = $optval;
                    } else {
                        $optstr = esc_html($key) . ' : ' . nl2br(esc_html(urldecode($value)));
                        $optmap[esc_html($key)] = nl2br(esc_html(urldecode($value)));
                    }
                }
                if (!empty($optstr)) {
                    $optstrs[] = $optstr;
                }
            }
        }
        $row['optstrs'] = $optstrs;
        $row['optmap'] = $optmap;
        $row['itemDeleted'] = false;
        $p = get_post($post_id);
        if ($p === null) {
            $row['itemDeleted'] = true;
            $row['price'] = $priceWhenAdded;
        } else {
            $pstatus = $wpdb->get_var($wpdb->prepare("SELECT post_status FROM {$wpdb->posts} WHERE ID = %d", $post_id));
            if ($pstatus === 'trash') {
                $row['itemDeleted'] = true;
            }
        }
        $sku_code = esc_attr(urldecode($sku));
        $itemCode = $usces->getItemCode($post_id);
        $itemName = $usces->getItemName($post_id);
        $cartItemName = $usces->getCartItemName($post_id, $sku_code);
        $itemRestriction = $usces->getItemRestriction($post_id);
        $formattedPrice = usces_crform($row['price'], true, false, 'return');
        $inStock = $usces->is_item_zaiko($post_id, $sku_code);
        $skuZaikonum = $usces->getItemZaikonum($post_id, $sku_code);
        $stockid = (int)$usces->getItemZaikoStatusId($post_id, $sku_code);
        $stock = $usces->getItemZaiko($post_id, $sku_code);
        $pictid = (int)$usces->get_mainpictid($itemCode);
        $cart_thumbnail_src = wp_get_attachment_image_src($pictid, 'thumbnail', true);
        $cart_thumbnail_src = $cart_thumbnail_src[0];
        $row['itemPermalink'] = get_permalink($post_id);
        $row['cartThumbnailSrc'] = $cart_thumbnail_src;
        $row['isgptekiyo'] = usces_is_gptekiyo($post_id, $sku_code, $row['quantity']);
        $row['inCart'] = isset($_SESSION['usces_cart'][$item['item_serial']]) ? true : false;
        $row['itemCode'] = $itemCode;
        $row['itemName'] = $itemName;
        /**
         * Filters the cart item name
         *
         * @ignore
         * @param string $cart_item_name
         * @param array  $vars
         */
        $row['cartItemName'] = apply_filters(
            'usces_filter_cart_item_name',
            esc_html($cartItemName),
            [
                'post_id' => $post_id,
                'sku' => $sku,
            ]
        );
        $row['cartItemNameParts'] = explode('<br />', $row['cartItemName']);
        $row['itemRestriction'] = $itemRestriction;
        $row['formattedPrice'] = $formattedPrice;
        $row['inStock'] = $inStock;
        $row['skuZaikonum'] = $skuZaikonum;
        $row['stockid'] = $stockid;
        $row['stock'] = $stock;
        $row['optionsAreValid'] = Validation::optionsAreValid($post_id, is_array($options) ? $options : []);

        /*
         * The following properties are for HTML and CSS. In general, it's bad practice to mix raw data with
         * display data. But for our case, we use WordPress PHP hooks to allow for customization of these values
         * AND we update HTML and CSS with JavaScript so it makes the most sense to set the values in one place.
         */
        $display = Master::getFilterableValues();
        $btnprimary = $display['btnprimary'];
        $cartButtonClass = "ui wcexwl add-to-cart-btn ${btnprimary} tiny fluid button";
        $cartButtonText = __('To Cart', 'wcexwl');
        $icon = 'cart';
        if ($row['inCart']) {
            $cartButtonClass = "ui wcexwl add-to-cart-btn ${btnprimary} tiny fluid basic disabled button";
            $cartButtonText = __('Added to Cart', 'wcexwl');
            $icon = 'check';
        }
        /**
         * Filters the 'Add to Cart' or 'Added to Cart' button CSS class on the wishlist page
         *
         * @important
         * @param string $cartButtonClass
         * @param array  $row Array of row contents already added
         */
        $row['cartButtonClass'] = apply_filters('wcexwl_filter_wlpage_cart_btn_class', $cartButtonClass, $row);
        /**
         * Filters the 'Add to Cart' or 'Added to Cart' button text on the wishlist page
         *
         * @important
         * @param string $cartButtonText
         * @param array  $row Array of row contents already added
         */
        $row['cartButtonText'] = apply_filters('wcexwl_filter_wlpage_cart_btn_text', $cartButtonText, $row);
        /**
         * Filters the 'Add to Cart' or 'Added to Cart' button icon on the wishlist page
         *
         * @important
         * @param string $icon
         * @param array  $row Array of row contents already added
         */
        $row['icon'] = apply_filters('wcexwl_filter_wlpage_tocart_btn_icon', $icon, $row);
        /**
         * Filters the 'Delete' button CSS class on the wishlist page
         *
         * @important
         * @param string $class
         * @param array  $row Array of row contents already added
         */
        $row['deleteButtonClass'] = apply_filters('wcexwl_filter_wlpage_delete_btn_class', 'ui tiny fluid button', $row);
        /**
         * Filters the 'Unit price' label text for an item on the wishlist page
         *
         * @important
         * @param string $text
         * @param array  $row Array of row contents already added
         */
        $row['unitPriceLabel'] = apply_filters('wcexwl_filter_wlpage_unit_price_label', __('Unit price', 'wcexwl'), $row);
        /**
         * Filters the 'Stock status' label text for an item on the wishlist page
         *
         * @important
         * @param string $text
         * @param array  $row Array of row contents already added
         */
        $row['stockStatusLabel'] = apply_filters('wcexwl_filter_wlpage_stock_status_label', __('stock status', 'wcexwl'), $row);
        /**
         * Filters the 'To Item Page' button text for an item on the wishlist page
         *
         * @important
         * @param string $text
         * @param array  $row Array of row contents already added
         */
        $row['toItemPageButtonText'] = apply_filters('wcexwl_filter_wlpage_invalid_options_to_item_page_text', __('To Item Page', 'wcexwl'), $row);
        /**
         * Filters the 'Delete' button text for an item on the wishlist page
         *
         * @important
         * @param string $text
         * @param array  $row Array of row contents already added
         */
        $row['deleteButtonText'] = apply_filters('wcexwl_filter_wlpage_delete_btn_text', __('Delete', 'usces'), $row);
        /**
         * Filters the warning message displayed for an item on the wishlist page whose selected options are no
         * longer valid
         *
         * @important
         * @param string $text
         * @param array  $row Array of row contents already added
         */
        $row['changedOptsText'] = apply_filters(
            'wcexwl_filter_wlpage_item_opts_changed_info_text',
            __('Options have changed for this item. Please add to cart from the item details page.', 'wcexwl'),
            $row
        );
        /**
         * Filters the message displayed for an item on the wishlist page which has been deleted
         *
         * @important
         * @param string $text
         * @param array  $row Array of row contents already added
         */
        $row['deletedInfoText'] = apply_filters(
            'wcexwl_filter_wlpage_item_deleted_info_text',
            __('This item is no longer available for purchase.', 'wcexwl'),
            $row
        );

        return $row;
    }

ソースを伸ばす ソースを縮める


関連アイテム #関連アイテム

Top ↑

使用するアイテム #使用するアイテム

使用するアイテム
説明
src/API/CRUD.php: wcexwl_filter_key_unserialize_options

商品オプションの配列をフィルタリングする

src/API/CRUD.php: wcexwl_filter_wlpage_cart_btn_class

お気に入りリストページの「カートに入れる」または「追加しました」ボタンのCSSクラスをフィルタリングする

src/API/CRUD.php: wcexwl_filter_wlpage_cart_btn_text

お気に入りリストページの「カートに入れる」または「追加しました」ボタンのテキストをフィルタリングする

src/API/CRUD.php: wcexwl_filter_wlpage_tocart_btn_icon

お気に入りリストページの「カートに入れる」または「追加しました」ボタンのアイコンをフィルタリングする

src/API/CRUD.php: wcexwl_filter_wlpage_delete_btn_class

お気に入りリストページの「削除」ボタンのCSSクラスをフィルタリングする

src/API/CRUD.php: wcexwl_filter_wlpage_unit_price_label

お気に入りリストページの商品の「単価」ラベルテキストをフィルタリングする

src/API/CRUD.php: wcexwl_filter_wlpage_stock_status_label

お気に入りリストページの商品の「在庫状態」ラベルテキストをフィルタリングする

src/API/CRUD.php: wcexwl_filter_wlpage_invalid_options_to_item_page_text

お気に入りリストページの商品の「商品詳細ページへ」ボタンのテキストをフィルタリングする

src/API/CRUD.php: wcexwl_filter_wlpage_delete_btn_text

お気に入りリストページの商品の「削除」ボタンのテキストをフィルタリングする

src/API/CRUD.php: wcexwl_filter_wlpage_item_opts_changed_info_text

お気に入りリストページにて選択されたオプションが有効でない商品に表示される警告メッセージをフィルタリングする

src/API/CRUD.php: wcexwl_filter_wlpage_item_deleted_info_text

お気に入りリストページにて削除された商品に表示されるメッセージをフィルタリングする

src/API/Validation.php: Validation::optionsAreValid()

与えられたオプションの配列が商品に対し有効かどうかを確認する

src/Master.php: Master::getFilterableValues()

フィルタリング可能なテキスト/css/表示の値の配列を返す

もっとみる (8件) 非表示

使用されるアイテム #使用されるアイテム

Top ↑

使用されるアイテム説明
src/API/CRUD.php: CRUD::getWishlistItemById()

IDでお気に入りリストの商品を返す

src/API/CRUD.php: CRUD::getWishlistItemBySerial()

シリアルでお気に入りリストの商品を返す

src/API/CRUD.php: CRUD::getAndBuildWishlistItems()

会員のお気に入りリストのそれぞれの商品データを返す

src/template-functions.php: wcexwl_get_wishlist_rows()

お気に入りリストの全アイテムのHTMLを返す

  • 新規会員登録
  • ログイン
    • プラグイン一覧
    • 会社概要
    • リリース情報
    • よくある質問
    • お役立ちコラム
    • お問い合わせ
    • 個人情報保護方針
    • 特定商取引法に基づく表記
    • 情報セキュリティ基本方針
    • 利用規約

アイベック合同会社は「Welcart」「Amazon Pay」の公式パートナーです。

※Amazon、Amazon.co.jp、Amazon Payおよびそれらのロゴは、Amazon.com,inc.またはその関連会社の商標です。

© 2025 Aivec llc All Rights Reserved.