• プラグイン一覧
    - 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 お気に入りリスト > 関数 > Item::addToWishlist
レファレンス
バージョン
3.1.6
絞り込み:
目的から探す
お気に入りデータを取得 お気に入りページのHTMLを取得 スナックバーアラート

目次

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

フック

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

ファンクション

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

関数

Item::addToWishlist( int $post_id, string $sku, array $item_option = array(), string $advance = '' )

パラメータにある商品情報でお気に入りリストに商品を追加する


パラメータ #パラメータ

$post_id

(数値) (必須)

$sku

(文字列) (必須) 必須 URLデコードされています

$item_option

(配列) (任意)

$advance

(文字列) (任意)


戻り値 #戻り値

Top ↑

(WCEXWL\Aivec\ResponseHandler\GenericError)

ソース #ソース

Top ↑

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

    public function addToWishlist($post_id, $sku, $item_option = [], $advance = '') {
        $exists = $this->guards->itemExists($post_id, $sku);
        if ($exists instanceof GenericError) {
            return $exists;
        }

        if (!defined('WCEX_WIDGET_CART')) {
            if (!empty($item_option)) {
                // by default we use `wcex_widget_cart`'s way of serializing option data but multi-select
                // option values are serialized differently when not using `wcex_widget_cart`. Because of this,
                // we have to transform multi-select option values when `wcex_widget_cart` is not being used.
                $item_option = self::convertWidgetCartItemOptionPayloadToWelcartDefault($item_option, $post_id, $sku);
            }

            // By default, Welcart serializes with the encoded SKU. `wcex_widget_cart` serializes with the decoded SKU.
            $sku = urlencode($sku);
        }

        $opterror = $this->guards->requiredOptionsProvided($post_id, $sku, $item_option);
        if ($opterror instanceof GenericError) {
            return $opterror;
        }

        $tempcart = new \usces_cart();
        if (!empty($item_option)) {
            // we are forced to set $_POST at runtime here since `in_serialize` uses $_POST internally
            $_POST['itemOption'] = $item_option;
        }
        $tempcart->in_serialize($post_id, $sku);
        unset($_POST['itemOption']);
        if (!empty($advance)) {
            $advance = $tempcart->wc_serialize($advance);
        }

        $hookargs = [
            'post_id' => $post_id,
            'sku' => $sku,
            'item_option' => $item_option,
            'advance' => $advance,
        ];

        $customerror = apply_filters('wcexwl_filter_item_add_to_wishlist_custom_validation', null, $hookargs);
        if ($customerror !== null) {
            return $customerror;
        }

        $serial = apply_filters('wcexwl_filter_item_add_to_wishlist_serial', $tempcart->serial, $hookargs);

        // check if logged in after all other checks pass so that we can add the item
        // to the wishlist automatically after a successful login
        $isloggedin = $this->guards->isLoggedIn();
        if ($isloggedin instanceof GenericError) {
            $isloggedin->setData($serial);
            return $isloggedin;
        }

        $res = CRUD::executeAddToWishlist($post_id, $sku, $serial, $advance);
        if ($res === false) {
            return $this->master->estore->getErrorResponse(Store::INTERNAL_SERVER_ERROR);
        }

        return true;
    }

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


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

Top ↑

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

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

お気に入りリストのテーブルに商品を挿入する

src/API/Item.php: Item::convertWidgetCartItemOptionPayloadToWelcartDefault()

WCEX Widget Cartと同様の方法でフォーマットされた商品オプションの配列が与えられた場合、 Welcartのデフォルトの商品オプションのデータ処理と異なる値をこのメソッドが変換するので、カートとお気に入りリストの同じ商品の間には不一致が存在しない

src/API/Item.php: wcexwl_filter_item_add_to_wishlist_custom_validation
src/API/Item.php: wcexwl_filter_item_add_to_wishlist_serial

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

Top ↑

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

$_POSTの値とともにお気に入りリストに商品を追加する

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

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

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

© 2025 Aivec llc All Rights Reserved.