우커머스 – 배송 보험

우커머스 – 배송 보험

WooCommerce 및 배송 옵션에는 배송하는 상품에 대한 보험을 제공하는 기본 제공 방법이 없습니다.

제품 가격에 포함

한 가지 옵션은 제품 가격에 보험 비용을 포함하는 것입니다. 그러나 이것은 고객에게 제품의 실제 비용에 대해 잘못된 인상을 준다는 단점이 있습니다.

다른 옵션

보험이 선택 사항인 경우

밑의 코드를 사용할 수 있습니다. 고객이 운송 보험 사용 여부를 선택할 수 있습니다.

  • 배송 보험이라는 상품을 추가(가격은 $3)
  • 상품을 “숨겨짐”으로 게시(카탈로그 가시성에서 선택가능)
add_action('woocommerce_cart_totals_after_shipping', 'wc_shipping_insurance_note_after_cart');
function wc_shipping_insurance_note_after_cart() {
global $woocommerce;
    $product_id = 669;
foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values ) {
    $_product = $values['data'];
    if ( $_product->id == $product_id )
        $found = true;
    }
    // if product not found, add it
if ( ! $found ):
?>
    <tr class="shipping">
        <th><?php _e( 'Shipping Insurance', 'woocommerce' ); ?></th>
        <td><a href="<?php echo do_shortcode('[add_to_cart_url id="669"]'); ?>"><?php _e( 'Add shipping insurance (+$3)' ); ?> </a></td>
    </tr>
<?php else: ?>
    <tr class="shipping">
        <th><?php _e( 'Shipping Insurance', 'woocommerce' ); ?></th>
        <td>$3</td>
    </tr>
<?php endif;
}

$product_id 변수를 앞에서 만든 상품 ID로 변경하고 결제할 때 이 숨겨진 상품을 장바구니에 추가하기만 하면됩니다.

보험이 선택 사항이 아닌 경우

Payment Gateway Based Fees 확장 기능이 더 잘 작동할 수 있습니다. 이렇게 하면 결제 수단에 비용을 추가하여 추가 요금을 청구할 수 있습니다.

원문: https://docs.woocommerce.com/document/offer-shipping-insurance/

코멘트 제출

Don`t copy text!