Skip to content

Instantly share code, notes, and snippets.

@bentasm1
Created April 25, 2016 20:54
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 bentasm1/416e053a2c310182c049489369208c18 to your computer and use it in GitHub Desktop.
Save bentasm1/416e053a2c310182c049489369208c18 to your computer and use it in GitHub Desktop.
WC Vendors Pro - Additional Information on Ships From section
/* WC Vendors Pro - Custom "Ships From" code provided by @pronet
* https://www.wcvendors.com/help/topic/custom-ships-from-how-to/
* Say you want to show more detailed location information under single product view “Ships From” section.
* This will show in addition the city and state/province.
*/
function custom_ships_from(){
global $post;
$vendor_id = WCV_Vendors::get_vendor_from_product( $post->ID );
$town = get_user_meta( $vendor_id, '_wcv_store_city', true );
$county = get_user_meta( $vendor_id, '_wcv_store_state', true );
if ( $town && $county && $county !='' ) {
$town = $town.', '.$county;
} elseif ( !$town && $county && $county !='' ) {
$town = $county;
}
if ( !$town || $town=='' ) {
$countries = WCVendors_Pro_Form_Helper::countries();
$store_country = WC()->countries->get_base_country();
$town = $countries[ strtoupper( $store_country ) ];
}
return array(
'store_country' => $town,
'wrapper_start' => '<br /><span class="wcvendors_ships_from">',
'wrapper_end' => '</span><br />',
'title' => __( 'Ships From: ', 'wcvendors-pro' )
);
}
add_filter('wcv_product_ships_from', 'custom_ships_from');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment