Skip to content

Instantly share code, notes, and snippets.

@fervous
Last active April 17, 2017 02:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fervous/256aea509c89191feffd330d2b27b5a0 to your computer and use it in GitHub Desktop.
Save fervous/256aea509c89191feffd330d2b27b5a0 to your computer and use it in GitHub Desktop.
make the "sold by" on the orders/view page a link - WC Vendors Pro (testing...)
/* change short description on product add/edit front end form */
remove_action( 'woocommerce_checkout_create_order_line_item', array( 'WCV_Vendor_Shop', 'add_vendor_to_order_item_meta' ), 50, 3 );
add_action( 'woocommerce_checkout_create_order_line_item', 'custom_add_vendor_to_order_item_meta' );
function custom_add_vendor_to_order_item_meta( $item, $cart_item_key, $values ) {
$cart = WC()->cart->get_cart();
$cart_item = $cart[ $cart_item_key ];
$product_id = $cart_item['data']->get_id();
$post = get_post( $product_id );
$vendor_id = $post->post_author;
$store_url = site_url( WC_Vendors::$pv_options->get_option( 'vendor_shop_permalink' ) .'/' .$vendor_id->pv_shop_slug );
$sold_by_label = WC_Vendors::$pv_options->get_option( 'sold_by_label' );
$sold_by = WCV_Vendors::is_vendor( $vendor_id ) ? sprintf( WCV_Vendors::get_vendor_sold_by( $vendor_id ) ): get_bloginfo( 'name' );
$sold_by_link = '<p><a href="'.$store_url.'">'.$sold_by.'</a></p>';
$item->add_meta_data( $sold_by_label , $sold_by_link );
} // custom_add_vendor_to_order_item_meta()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment