Skip to content

Commit

Permalink
現在のカゴの中 [戻る]ボタン 購入手続きへ遷移することがある EC-CUBE#803
Browse files Browse the repository at this point in the history
  • Loading branch information
seasoftjapan committed Dec 29, 2023
1 parent ca9c817 commit b356c06
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 26 deletions.
36 changes: 23 additions & 13 deletions data/class/pages/cart/LC_Page_Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,22 +284,32 @@ public function lfUpdateOrderTempid($pre_uniqid, $uniqid)
*/
public function lfGetCartPrevUrl(&$session, $referer)
{
if (!preg_match('/cart/', $referer)) {
if (!empty($session['cart_referer_url'])) {
$session['cart_prev_url'] = $session['cart_referer_url'];
unset($session['cart_referer_url']);
} else {
if (preg_match('/entry/', $referer)) {
$session['cart_prev_url'] = HTTPS_URL . 'entry/kiyaku.php';
} else {
$session['cart_prev_url'] = $referer;
}
// 妥当性チェック
if (!SC_Utils_Ex::isInternalUrl($referer)) {
return;
}

// 除外ページの場合、何もせず終了する。
$arrExclude = array(
ROOT_URLPATH . 'shopping/',
ROOT_URLPATH . 'cart/',
);

// リファラーから path を切り出す。
$netURL = new Net_URL($referer);
$referer_path = $netURL->path;

foreach ($arrExclude as $start) {
if (str_starts_with($referer_path, $start)) {
return;
}
}
// 妥当性チェック
if (!SC_Utils_Ex::sfIsInternalDomain($session['cart_prev_url'])) {
$session['cart_prev_url'] = '';

if (str_starts_with($referer_path, ROOT_URLPATH . 'entry/')) {
$referer = HTTPS_URL . 'entry/kiyaku.php';
}

$session['cart_prev_url'] = $referer;
}

/**
Expand Down
9 changes: 1 addition & 8 deletions data/class/pages/products/LC_Page_Products_Detail.php
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,7 @@ public function action()
case 'select':
case 'select2':
case 'selectItem':
/**
* モバイルの数量指定・規格選択の際に、
* $_SESSION['cart_referer_url'] を上書きさせないために、
* 何もせずbreakする。
*/
// nop
break;

default:
Expand Down Expand Up @@ -687,9 +683,6 @@ public function doAddFavoriteSphone(SC_Customer $objCustomer)
*/
public function doDefault()
{
// カート「戻るボタン」用に保持
$netURL = new Net_URL();
$_SESSION['cart_referer_url'] = $netURL->getURL();
}

/**
Expand Down
5 changes: 0 additions & 5 deletions data/class/pages/products/LC_Page_Products_List.php
Original file line number Diff line number Diff line change
Expand Up @@ -578,11 +578,6 @@ public function doDefault(&$objProduct, &$objFormParam)
SC_Response_Ex::actionExit();
}
$js_fnOnLoad .= $this->lfSetSelectedData($this->arrProducts, $this->arrForm, $arrErr, $target_product_id);
} else {
// カート「戻るボタン」用に保持
$netURL = new Net_URL();
//該当メソッドが無いため、$_SESSIONに直接セット
$_SESSION['cart_referer_url'] = $netURL->getURL();
}

$this->tpl_javascript .= 'function fnOnLoad() {' . $js_fnOnLoad . '}';
Expand Down

0 comments on commit b356c06

Please sign in to comment.