関数
PurchaseSanityChecks::exitAddToCartWithError( string $message )
説明 説明
This method mirrors the exit logic in $usces->incart_check()
. If only the exit logic existed in its own function we could call it directly……
- $message
(文字列) (必須)
ファイル: src/API/PurchaseSanityChecks.php
public static function exitAddToCartWithError($message) { $ids = array_keys($_POST['inCart']); $post_id = $ids[0]; $skus = array_keys($_POST['inCart'][$post_id]); $sku = urldecode($skus[0]); $_SESSION['usces_singleitem']['error_message'] = [$post_id => [$sku => $message]]; $url = esc_url($_POST['usces_referer']); if (false === strpos($_POST['usces_referer'], 'http')) { $parse_url = parse_url(get_home_url()); $port = ''; if ($parse_url['host'] === 'localhost' && !empty($parse_url['port'])) { $port = ':' . $parse_url['port']; } $url = $parse_url['scheme'] . '://' . $parse_url['host'] . $port . $url; } header('location: ' . $url . apply_filters('usces_filter_incart_redirect', '#cart_button', $post_id, $sku)); exit; }