Skip to content

Instantly share code, notes, and snippets.

@agusmu
Forked from fervous/functions.php
Created October 10, 2016 02:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agusmu/50edfdbf4f10b4bb14c362304c1eb1fe to your computer and use it in GitHub Desktop.
Save agusmu/50edfdbf4f10b4bb14c362304c1eb1fe to your computer and use it in GitHub Desktop.
Show shipping by vendor next to item in cart
// 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