Skip to content

Instantly share code, notes, and snippets.

@racmanuel
Last active May 4, 2021 21:50
Show Gist options
  • Save racmanuel/17eeb18b06f81494f383cd6eb0690fd9 to your computer and use it in GitHub Desktop.
Save racmanuel/17eeb18b06f81494f383cd6eb0690fd9 to your computer and use it in GitHub Desktop.
Show different archive-product.php if is a WC Vendor or is a Normal User
<?php
/**
* Show different archive-product.php if is a WC Vendor or is a Normal User
* Put this file in you folder theme or child theme in woocommerce folder
*
* The Template for displaying product archives, including the main shop page which is a post type archive
*
* This template can be overridden by copying it to yourtheme/woocommerce/archive-product.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates
* @version 3.4.0
* @author racmanuel
*/
defined('ABSPATH') || exit;
/*
* Check if is a Product of Marketplace
* if is true show the template with horizontal view of products
* if is false show the template with vertical view of products
*/
$vendor_shop = urldecode(get_query_var('vendor_shop'));
$vendor_id = WCV_Vendors::get_vendor_id($vendor_shop);
if ($vendor_id) {
include get_theme_file_path( '/woocommerce/archive-product-vendors.php');
} else {
include get_theme_file_path( '/woocommerce/archive-product-store.php');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment