関数
Redirect::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.
戻り値 戻り値
ファイル: src/Routes/Redirect.php
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; } }