-
-
Save bentasm1/f12da929e1042b4c35b58bdbd115f93e to your computer and use it in GitHub Desktop.
Add vendor shipping cost to cart item
This file contains hidden or 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
<?php | |
// Add this to your themes function.php | |
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="">Vendor Shipping : ' . get_woocommerce_currency_symbol(). $shipping_rate->fee . '</span>'; | |
} else { | |
echo $title; | |
} | |
} //wcv_shipping_cart_item() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment