first commit 2
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
|
||||
|
||||
// 💡 [사용법]
|
||||
// $it_id = '상품코드'; // 필수
|
||||
// $qty = 1; // 선택 (기본값 1)
|
||||
// $btn_text = '바로구매'; // 선택 (버튼 텍스트)
|
||||
// include(G5_THEME_PATH.'/shop/buy_module/form_buy.php');
|
||||
|
||||
$it_id = isset($it_id) ? $it_id : '';
|
||||
$qty = isset($qty) ? $qty : 1;
|
||||
$btn_text = isset($btn_text) ? $btn_text : '바로구매';
|
||||
|
||||
if (!$it_id) {
|
||||
echo '<!-- 상품 ID가 설정되지 않았습니다. -->';
|
||||
return;
|
||||
}
|
||||
?>
|
||||
|
||||
<form name="fbuy_<?php echo $it_id; ?>" method="post" action="<?php echo G5_SHOP_URL; ?>/cartupdate.php" style="display:inline-block;">
|
||||
<input type="hidden" name="it_id[]" value="<?php echo $it_id; ?>">
|
||||
<input type="hidden" name="sw_direct" value="1"> <!-- 1: 바로구매, 0: 장바구니 -->
|
||||
<input type="hidden" name="ct_qty[<?php echo $it_id; ?>]" value="<?php echo $qty; ?>">
|
||||
|
||||
<button type="submit" class="btn_buy_direct"><?php echo $btn_text; ?></button>
|
||||
</form>
|
||||
|
||||
<style>
|
||||
.btn_buy_direct {
|
||||
display: inline-block;
|
||||
padding: 10px 20px;
|
||||
background: #ff3061;
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
}
|
||||
.btn_buy_direct:hover {
|
||||
background: #e62a55;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가
|
||||
|
||||
// 💡 [사용법]
|
||||
// $it_id = '상품코드'; // 필수
|
||||
// $qty = 1; // 선택 (기본값 1)
|
||||
// $btn_text = '바로구매'; // 선택 (버튼 텍스트)
|
||||
// include(G5_THEME_PATH.'/shop/buy_module/link_btn.php');
|
||||
|
||||
$it_id = isset($it_id) ? $it_id : '';
|
||||
$qty = isset($qty) ? $qty : 1;
|
||||
$btn_text = isset($btn_text) ? $btn_text : '바로구매';
|
||||
|
||||
// 처리 파일 경로 (웹 URL)
|
||||
$action_url = G5_THEME_URL.'/shop/buy_module/link_buy_action.php';
|
||||
|
||||
if (!$it_id) {
|
||||
echo '<!-- 상품 ID가 설정되지 않았습니다. -->';
|
||||
return;
|
||||
}
|
||||
?>
|
||||
|
||||
<a href="<?php echo $action_url; ?>?it_id=<?php echo $it_id; ?>&qty=<?php echo $qty; ?>" class="btn_buy_link"><?php echo $btn_text; ?></a>
|
||||
|
||||
<style>
|
||||
.btn_buy_link {
|
||||
display: inline-block;
|
||||
padding: 10px 20px;
|
||||
background: #3f51b5;
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
}
|
||||
.btn_buy_link:hover {
|
||||
background: #2c3e50;
|
||||
color: #fff;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
include_once('./_common.php');
|
||||
|
||||
// GET 파라미터 받기
|
||||
$it_id = isset($_GET['it_id']) ? preg_replace('/[^a-z0-9_\-]/i', '', $_GET['it_id']) : '';
|
||||
$qty = isset($_GET['qty']) ? (int)$_GET['qty'] : 1;
|
||||
|
||||
if (!$it_id) {
|
||||
alert('상품 ID가 없습니다.');
|
||||
}
|
||||
|
||||
// 상품 존재 여부 확인
|
||||
$it = get_shop_item($it_id, true);
|
||||
if (!$it['it_id']) {
|
||||
alert('등록된 상품이 없습니다.');
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- 자동으로 POST 전송 -->
|
||||
<form name="fdirect_action" method="post" action="<?php echo G5_SHOP_URL; ?>/cartupdate.php">
|
||||
<input type="hidden" name="it_id[]" value="<?php echo $it_id; ?>">
|
||||
<input type="hidden" name="sw_direct" value="1">
|
||||
<input type="hidden" name="ct_qty[<?php echo $it_id; ?>]" value="<?php echo $qty; ?>">
|
||||
</form>
|
||||
|
||||
<script>
|
||||
document.fdirect_action.submit();
|
||||
</script>
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
include_once('./_common.php');
|
||||
|
||||
// 1. 필수 데이터 확인
|
||||
$it_id = isset($_REQUEST['it_id']) ? preg_replace('/[^a-z0-9_\-]/i', '', $_REQUEST['it_id']) : '';
|
||||
$qty = isset($_REQUEST['qty']) ? (int)$_REQUEST['qty'] : 1;
|
||||
|
||||
if (!$it_id) alert('상품 ID가 없습니다.');
|
||||
|
||||
// 2. 상품 정보 가져오기
|
||||
$it = get_shop_item($it_id, true);
|
||||
if (!$it['it_id']) alert('등록된 상품이 없습니다.');
|
||||
|
||||
// 3. 주문 번호 생성 및 세션 설정
|
||||
$od_id = get_uniqid();
|
||||
set_session('ss_order_id', $od_id);
|
||||
|
||||
// 4. 장바구니에 담기 (기존 장바구니 비우고 새로 담기 - 원클릭 결제 전용)
|
||||
// 주의: 기존 장바구니를 비우는 것이 부담스럽다면, 별도의 장바구니 ID를 써야 하지만 복잡해짐.
|
||||
// 여기서는 '바로구매' 로직을 따름.
|
||||
$cart_id = $od_id; // 주문번호를 장바구니 ID로 사용
|
||||
set_session('ss_cart_direct', $cart_id);
|
||||
|
||||
// 장바구니 테이블에 insert
|
||||
$sql = " insert into {$g5['g5_shop_cart_table']}
|
||||
set od_id = '$cart_id',
|
||||
mb_id = '{$member['mb_id']}',
|
||||
it_id = '$it_id',
|
||||
it_name = '".addslashes($it['it_name'])."',
|
||||
ct_status = '쇼핑',
|
||||
ct_price = '".get_price($it)."',
|
||||
ct_point = '{$it['it_point']}',
|
||||
ct_point_use = 0,
|
||||
ct_stock_use = 0,
|
||||
ct_qty = '$qty',
|
||||
ct_time = '".G5_TIME_YMDHIS."',
|
||||
ct_ip = '{$_SERVER['REMOTE_ADDR']}',
|
||||
ct_send_cost = 0,
|
||||
ct_direct = '1',
|
||||
ct_select = '1' ";
|
||||
sql_query($sql);
|
||||
|
||||
// 5. 주문서 페이지로 이동하되, 자동 실행 모드로 설정
|
||||
// orderform.php를 직접 수정하지 않고는 결제창 자동 팝업이 어렵습니다.
|
||||
// 따라서, 여기서는 orderform.php로 이동시키되, URL 파라미터로 'auto_pay=1'을 넘겨서
|
||||
// orderform.php 하단 스크립트에서 이를 감지하고 결제 버튼을 클릭하게 하는 방식을 추천합니다.
|
||||
|
||||
goto_url(G5_SHOP_URL.'/orderform.php?sw_direct=1&auto_pay=1');
|
||||
?>
|
||||
Reference in New Issue
Block a user