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

目次

  • ソース
  • 関数

フック

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

ファンクション

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

クラス

Redirect

Handles redirects to the wishlist page

ソース #ソース

ファイル: src/Routes/Redirect.php

class Redirect
{
    const REDIRECT_KEY_ADD_TO_WISHLIST = 'wcexwlAddToWishlist';
    const REDIRECT_KEY_ADD_TO_WISHLIST_BY_SERIAL = 'wcexwlAddToWishlistBySerial';

    /**
     * Master object
     *
     * @var Master
     */
    private $master;

    /**
     * Injects `Master` object
     *
     * @author Evan D Shaw <evandanielshaw@gmail.com>
     * @param Master $master
     * @return void
     */
    public function __construct(Master $master) {
        $this->master = $master;
    }

    /**
     * Registers hooks for redirection
     *
     * @author Evan D Shaw <evandanielshaw@gmail.com>
     * @return void
     */
    public function init() {
        add_action('usces_action_after_login', [$this, 'handleAddToWishlistRedirectOnLogin'], 1, 1);
    }

    /**
     * If the user attempted to add an item to their wishlist and was redirected
     * to the login page, add that item after a successful login and redirect to
     * the wishlist page.
     *
     * @author Evan D Shaw <evandanielshaw@gmail.com>
     * @global \usc_e_shop $usces
     * @return void
     */
    public function handleAddToWishlistRedirectOnLogin() {
        global $usces;

        // we have to do this because the hook is called before cookie is set. {@see usceshop.class.php LINE 3797}
        $usces->set_cookie($usces->get_cookie());

        if (!empty($_POST[self::REDIRECT_KEY_ADD_TO_WISHLIST])) {
            $paramstring = urldecode((string)$_POST[self::REDIRECT_KEY_ADD_TO_WISHLIST]);
            parse_str($paramstring, $item);
            $backuppost = $_POST;
            foreach ($item as $key => $val) {
                $_POST[$key] = $val;
            }
            $added = (new API\Item($this->master))->addToWishlist(
                $item['postId'],
                $item['sku'],
                isset($item['itemOption']) ? $item['itemOption'] : [],
                isset($item['advance']) ? $item['advance'] : ''
            );
            foreach ($item as $key => $val) {
                if (isset($backuppost[$key])) {
                    $_POST[$key] = $backuppost[$key];
                } else {
                    unset($_POST[$key]);
                }
            }
            if ($added !== true) {
                return;
            }
            wp_safe_redirect(WCEXWL_PAGE_URL);
            exit;
        } elseif (!empty($_POST[self::REDIRECT_KEY_ADD_TO_WISHLIST_BY_SERIAL])) {
            $cart = isset($_SESSION['usces_cart']) ? $_SESSION['usces_cart'] : [];
            $serials = (array)$_POST[self::REDIRECT_KEY_ADD_TO_WISHLIST_BY_SERIAL];
            $cartapi = new API\Cart($this->master);
            $erroroccured = false;
            foreach ($serials as $encodedserial) {
                $serial = urldecode($encodedserial);
                $advance = isset($cart[$serial]['advance']) ? $cart[$serial]['advance'] : '';
                $added = $cartapi->addToWishlistBySerial($serial, $advance);
                if ($added !== true) {
                    $erroroccured = true;
                }
            }
            if ($erroroccured === true) {
                return;
            }
            wp_safe_redirect(WCEXWL_PAGE_URL);
            exit;
        }
    }
}

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


関数 #関数

Top ↑

  • __construct — Injects `Master` object
  • handleAddToWishlistRedirectOnLogin — If the user attempted to add an item to their wishlist and was redirected to the login page, add that item after a successful login and redirect to the wishlist page.
  • init — Registers hooks for redirection

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

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

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

© 2025 Aivec llc All Rights Reserved.