테스트 사이트 - 개발 중인 베타 버전입니다

상품 옵션 가격 표시에 관한 질문이 있습니다.

슈가 10년 전 조회 4,351

http://sir.co.kr/qa/?wr_id=68501&stx=%EC%98%B5%EC%85%98+%EA%B0%80%EA%B2%A9&sst=wr_num&unanswered=0&s_tag=" target="_self">http://sir.co.kr/qa/?wr_id=68501&stx=%EC%98%B5%EC%85%98+%EA%B0%80%EA%B2%A9&sst=wr_num&unanswered=0&s_tag= 

 

예전에 이 글을 보고 작은별님의 답변을 참고하여 모든 제품의 상품 옵션 가격을 보이지 않게 해두었습니다.

 

그런데 이렇게 가격을 보이지 않게 해둔 상태에서 특정 상품의 가격은 보이게 하고 싶을 때,

예를 들어 그 상품의 $it_id가 LEAF000023일 경우, lib/shop.lib.php에서 이렇게 수정하면 괜찮을까요??

 

기존 코드

</span></span></p><p><span style="color: rgb(125, 125, 125); font-family: 나눔고딕, NanumGothic, sans-serif; font-size: 9pt; line-height: normal;">if(strlen($opt_id[1])) {</span></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 9pt; line-height: normal; font-family: 나눔고딕, NanumGothic, sans-serif; color: rgb(125, 125, 125);">    if($row['io_price'] >= 0)</span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 9pt; line-height: normal; font-family: 나눔고딕, NanumGothic, sans-serif; color: rgb(125, 125, 125);">        $price = '  ';//+ '.number_format($row['io_price']).'원';</span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 9pt; line-height: normal; font-family: 나눔고딕, NanumGothic, sans-serif; color: rgb(125, 125, 125);">    else</span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 9pt; line-height: normal; font-family: 나눔고딕, NanumGothic, sans-serif; color: rgb(125, 125, 125);">        $price = '   ';//.number_format($row['io_price']).'원';</span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 9pt; line-height: normal; font-family: 나눔고딕, NanumGothic, sans-serif; color: rgb(125, 125, 125);">    $io_stock_qty = get_option_stock_qty($it_id, $row['io_id'], $row['io_type']);</span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 12px; line-height: normal;">
</span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 9pt; line-height: normal; font-family: 나눔고딕, NanumGothic, sans-serif; color: rgb(125, 125, 125);">    if($io_stock_qty < 1)</span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 9pt; line-height: normal; font-family: 나눔고딕, NanumGothic, sans-serif; color: rgb(125, 125, 125);">        $soldout = '  [품절]';</span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 9pt; line-height: normal; font-family: 나눔고딕, NanumGothic, sans-serif; color: rgb(125, 125, 125);">    else</span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 9pt; line-height: normal; font-family: 나눔고딕, NanumGothic, sans-serif; color: rgb(125, 125, 125);">        $soldout = '';</span></font></p><p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 12px; line-height: normal;">
</span></font></p><span style="font-size: 9pt; font-family: 나눔고딕, NanumGothic, sans-serif; color: rgb(125, 125, 125);">    $options[$opt_id[0]][] = '<option value="'.$opt_id[1].','.$row['io_price'].','.$io_stock_qty.'">'.$opt_id[1].$price.$soldout.'</option>';</span>
<p><font color="#7f7f7f" face="돋움, Dotum, sans-serif"><span style="font-size: 9pt; line-height: normal; font-family: 나눔고딕, NanumGothic, sans-serif; color: rgb(125, 125, 125);">        }</span></font><span style="color: rgb(127, 127, 127); font-family: 돋움, Dotum, sans-serif; font-size: 9pt; line-height: normal;"> </span></p><p><span style="color: rgb(127, 127, 127); font-family: 돋움, Dotum, sans-serif; font-size: 12px; line-height: normal;"><span style="font-family: 나눔고딕, NanumGothic, sans-serif; font-size: 9pt; color: rgb(125, 125, 125);">

 

수정 코드

</span></span><span style="font-size: 9pt; line-height: 1.5; font-family: 나눔고딕, NanumGothic, sans-serif; color: rgb(125, 125, 125);">​</span></p><p><span style="font-size: 11pt; line-height: 1.5;"></span><span style="font-family: 나눔고딕, NanumGothic, sans-serif; font-size: 9pt; color: rgb(125, 125, 125);">if(strlen($opt_id[1])) {</span></p><p><span style="font-family: 나눔고딕, NanumGothic, sans-serif; font-size: 9pt; color: rgb(125, 125, 125);">    if($it_id == "LEAF</span><span style="font-size: 9pt; line-height: 1.5; font-family: 나눔고딕, NanumGothic, sans-serif; color: rgb(125, 125, 125);">000023</span><span style="font-size: 9pt; line-height: 1.5; font-family: 나눔고딕, NanumGothic, sans-serif; color: rgb(125, 125, 125);">​</span><span style="font-size: 9pt; line-height: 1.5; font-family: 나눔고딕, NanumGothic, sans-serif; color: rgb(125, 125, 125);">")</span></p><p><span style="font-family: 나눔고딕, NanumGothic, sans-serif; font-size: 9pt; color: rgb(125, 125, 125);">        $price = '  + '.number_format($row['io_price']).'원';</span></p><p><span style="font-family: 나눔고딕, NanumGothic, sans-serif; font-size: 9pt; color: rgb(125, 125, 125);">    else if($row['io_price'] >= 0)</span></p><p><span style="font-family: 나눔고딕, NanumGothic, sans-serif; font-size: 9pt; color: rgb(125, 125, 125);">        $price = '  ';//+ '.number_format($row['io_price']).'원';</span></p><p><span style="font-family: 나눔고딕, NanumGothic, sans-serif; font-size: 9pt; color: rgb(125, 125, 125);">    else</span></p><p><span style="font-family: 나눔고딕, NanumGothic, sans-serif; font-size: 9pt; color: rgb(125, 125, 125);">        $price = '   ';//.number_format($row['io_price']).'원';</span></p><p><span style="font-family: 나눔고딕, NanumGothic, sans-serif; font-size: 9pt; color: rgb(125, 125, 125);">    $io_stock_qty = get_option_stock_qty($it_id, $row['io_id'], $row['io_type']);</span></p><p><span style="font-size: 9pt;"> </span></p><p><span style="font-family: 나눔고딕, NanumGothic, sans-serif; font-size: 9pt; color: rgb(125, 125, 125);">    if($io_stock_qty < 1)</span></p><p><span style="font-family: 나눔고딕, NanumGothic, sans-serif; font-size: 9pt; color: rgb(125, 125, 125);">        $soldout = '  [품절]';</span></p><p><span style="font-family: 나눔고딕, NanumGothic, sans-serif; font-size: 9pt; color: rgb(125, 125, 125);">    else</span></p><p><span style="font-family: 나눔고딕, NanumGothic, sans-serif; font-size: 9pt; color: rgb(125, 125, 125);">        $soldout = ''</span></p><p><span style="font-size: 9pt;"> </span></p><p><span style="font-family: 나눔고딕, NanumGothic, sans-serif; font-size: 9pt; color: rgb(125, 125, 125);">    $options[$opt_id[0]][] = '<option value="'.$opt_id[1].','.$row['io_price'].','.$io_stock_qty.'">'.$opt_id[1].$price.$soldout.'</option>';</span></p><p><span style="font-family: 나눔고딕, NanumGothic, sans-serif; font-size: 9pt; color: rgb(125, 125, 125);">        }</span><span style="font-size: 9pt; line-height: 1.5;"> </span></p><p><span style="font-size: 11pt; line-height: 1.5;"></span><span style="color: rgb(127, 127, 127); font-family: 돋움, Dotum, sans-serif; font-size: 12px; line-height: normal;"><span style="font-family: 나눔고딕, NanumGothic, sans-serif; font-size: 9pt; color: rgb(125, 125, 125);">

 

우선 제가 확인해 본 결과 큰 문제없는 것 같은데 앞으로 문제가 발생할 수 있다거나 그렇지는 않겠죠?ㅠㅠ

조언 부탁드립니다!

댓글을 작성하려면 로그인이 필요합니다.

답변 1개

P
9년 전

헐 이렇게 코딩을 하시다니

if문의 의미를 잘 모르시네요

 

경우를 나누는게    if($it_id == "LEAF000023​") 문은

상품 가격 보이는 조건안에 들어가야 합니다. 

 

if문의 원래 의미부터 파악하셔야 할 듯합니다 

 

 

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인