Home / eCommerce / Display Vendor Policies on the Vendor Shop Page
Duplicate Snippet

Embed Snippet on Your Site

Display Vendor Policies on the Vendor Shop Page

By default, we only show the Vendor Policies on the Single Product Page. Please use the following code snippet if you'd like to show them on the vendor shop page.

Code Preview
php
<?php
if ( ! function_exists( 'wcvendors_show_vendor_policies' ) ) {
	/**
	 * Show WC Vendors vendor policies on the vendor store page
	 */
	function wcvendors_show_vendor_policies() {
		if ( ! is_wcv_pro_active() ) {
			return;
		}
		if ( ! WCV_Vendors::is_vendor_page() ) {
			return;
		}
		$vendor_shop = urldecode( get_query_var( 'vendor_shop' ) );
		$vendor_id   = WCV_Vendors::get_vendor_id( $vendor_shop );
		if ( ! $vendor_id ) {
			return;
		}
		$private_policy    = get_user_meta( $vendor_id, 'wcv_policy_privacy', true );
		$term_policy       = get_user_meta( $vendor_id, 'wcv_policy_terms', true );
		$shipping_settings = get_user_meta( $vendor_id, '_wcv_shipping', true );
		$shipping_policy   = isset( $shipping_settings['shipping_policy'] ) ? $shipping_settings['shipping_policy'] : '';
		$refund_policy     = isset( $shipping_settings['return_policy'] ) ? $shipping_settings['return_policy'] : '';
		if ( ! empty( $private_policy ) ) {
			echo '<div class="vendor-policy">';
			echo '<h2>Private Policy</h2>';
			echo '<div class="vendor-policy-content">' . wp_kses_post( $private_policy ) . '</div>';
			echo '</div>';
		}
		if ( ! empty( $term_policy ) ) {
			echo '<div class="vendor-policy">';
			echo '<h2>Terms of Service</h2>';
			echo '<div class="vendor-policy-content">' . wp_kses_post( $term_policy ) . '</div>';
			echo '</div>';
		}
		if ( ! empty( $shipping_policy ) ) {
			echo '<div class="vendor-policy">';
			echo '<h2>Shipping Policy</h2>';
			echo '<div class="vendor-policy-content">' . wp_kses_post( $shipping_policy ) . '</div>';
			echo '</div>';
		}
		if ( ! empty( $refund_policy ) ) {
			echo '<div class="vendor-policy">';
			echo '<h2>Refund Policy</h2>';
			echo '<div class="vendor-policy-content">' . wp_kses_post( $refund_policy ) . '</div>';
			echo '</div>';
		}
	}
	add_action( 'woocommerce_after_main_content', 'wcvendors_show_vendor_policies', 100 );
}

Comments

Add a Comment