Answer the question
In order to leave comments, you need to log in
WooCommerce - how to replace a product link in /shop with a link from attributes?
Hello.
The task is to implement a similar catalog in a simplified form on WP (you only need a Logo, Name, Link to the factory website). In order to properly filter alphabetically, I only thought of doing it all through WooCommerce, whichever is easier to implement:
1. in the mini-card: Factory logo, Factory name and when clicked, you go to the factory website
or
2. in the mini-card: Factory logo , Name of the factory, Active link to the factory website,
as I understand it, the link to the factory website in this case is written in the attributes so that you can simply import from Excel? How to insert it into the template in this case?
Since the site is not an IM and the product card is not needed at all, I googled this option to remove the link to the card itself:
remove_action( 'woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open', 10 );
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_product_link_close', 5 );
Answer the question
In order to leave comments, you need to log in
Yeah baby!
I understand that for many users this is baby talk, but for me it's a victory))
How I implemented my plan.
. Data output in the mini-card in the store /shop is done using hooks in the theme's content-product.php file.
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
global $product, $woocommerce_loop;
// Ensure visibility
if ( empty( $product ) || ! $product->is_visible() ) {
return;
}
// Store column count for displaying the grid
if ( empty( $woocommerce_loop['columns'] ) ) {
$woocommerce_loop['columns'] = apply_filters( 'loop_shop_columns', 3 );
}
// Extra post classes
$classes = array();
if ($woocommerce_loop['columns'] == 2) {
$classes[] = 'col-md-6';
}elseif($woocommerce_loop['columns'] == 4){
$classes[] = 'col-md-3';
}elseif($woocommerce_loop['columns'] == 6){
$classes[] = 'col-md-2';
}else{
$classes[] = 'col-md-4';
}
?>
<div <?php post_class( $classes ); ?>>
<div class="product-item">
<?php
/**
* woocommerce_before_shop_loop_item hook.
*
* @hooked woocommerce_template_loop_product_link_open - 10
*/
do_action( 'woocommerce_before_shop_loop_item' );
?>
<b><a href="<?php the_permalink(); ?>" class="products-warp"></b>
<?php
/**
* woocommerce_before_shop_loop_item_title hook.
*
* @hooked woocommerce_template_loop_product_thumbnail - 10
* @hooked woocommerce_show_product_loop_sale_flash - 10
*/
do_action( 'woocommerce_before_shop_loop_item_title' );
?>
<b></a></b>
<div class="product-info">
<b><a href="<?php the_permalink(); ?>"></b>
<?php
/**
* woocommerce_shop_loop_item_title hook.
*
* @hooked woocommerce_template_loop_product_title - 10
*/
do_action( 'woocommerce_shop_loop_item_title' );
?>
<b></a></b>
<?php
/**
* woocommerce_after_shop_loop_item_title hook.
*
* @hooked woocommerce_template_loop_rating - 5
* @hooked woocommerce_template_loop_price - 10
*/
<b>do_action( 'woocommerce_after_shop_loop_item_title' );</b>
/**
* woocommerce_after_shop_loop_item hook.
*
* @hooked woocommerce_template_loop_product_link_close - 5
* @hooked woocommerce_template_loop_add_to_cart - 10
*/
<b>do_action( 'woocommerce_after_shop_loop_item' );</b>
?>
</div>
</div>
</div>
<a href="http://www.ararredamenti.it/" rel="noopener" target="_blank">www.ararredamenti.it</a>
(Excel to help). Accordingly, now we need to add a hook that would display a short description for us. /**
* Ссылки на фабрики в /shop.
*/
add_action( 'woocommerce_brands_link', 'woocommerce_template_single_excerpt', 10 );
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
global $product, $woocommerce_loop;
// Ensure visibility
if ( empty( $product ) || ! $product->is_visible() ) {
return;
}
// Store column count for displaying the grid
if ( empty( $woocommerce_loop['columns'] ) ) {
$woocommerce_loop['columns'] = apply_filters( 'loop_shop_columns', 3 );
}
// Extra post classes
$classes = array();
if ($woocommerce_loop['columns'] == 2) {
$classes[] = 'col-md-6';
}elseif($woocommerce_loop['columns'] == 4){
$classes[] = 'col-md-3';
}elseif($woocommerce_loop['columns'] == 6){
$classes[] = 'col-md-2';
}else{
$classes[] = 'col-md-4';
}
?>
<div <?php post_class( $classes ); ?>>
<div class="product-item">
<?php
/**
* woocommerce_before_shop_loop_item hook.
*
* @hooked woocommerce_template_loop_product_link_open - 10
*/
do_action( 'woocommerce_before_shop_loop_item' );
?>
<?php
/**
* woocommerce_before_shop_loop_item_title hook.
*
* @hooked woocommerce_template_loop_product_thumbnail - 10
* @hooked woocommerce_show_product_loop_sale_flash - 10
*/
do_action( 'woocommerce_before_shop_loop_item_title' );
?>
<div class="product-info">
<?php
/**
* woocommerce_shop_loop_item_title hook.
*
* @hooked woocommerce_template_loop_product_title - 10
*/
do_action( 'woocommerce_shop_loop_item_title' );
do_action( 'woocommerce_brands_link' );
?>
<?php
?>
</div>
</div>
</div>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question