-
-
Save agusmu/50edfdbf4f10b4bb14c362304c1eb1fe to your computer and use it in GitHub Desktop.
Show shipping by vendor next to item in cart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SHIPPING IN CART | |
add_filter( 'woocommerce_cart_item_name', 'wcv_shipping_cart_item', 1, 3 ); | |
function wcv_shipping_cart_item( $title = null, $cart_item = null, $cart_item_key = null ) { | |
$settings = get_option( 'woocommerce_wcv_pro_vendor_shipping_settings' ); | |
$customer_address = array( 'country' => WC()->customer->get_shipping_country(), 'state' => WC()->customer->get_shipping_state() ); | |
$package = array( 'destination' => $customer_address ); | |
$shipping_rate = WCVendors_Pro_Shipping_Method::get_shipping_rate( $cart_item[ 'product_id' ], $cart_item['data']->post->post_author, $package, $settings ); | |
if( $cart_item_key && is_cart() ) { | |
echo $title. '<br /><span class=""><br>Shipping : ' . get_woocommerce_currency_symbol(). $shipping_rate->fee . '</span>'; | |
} else { | |
echo $title; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment