admin管理员组文章数量:1310178
I am using a plugin for a product carousel on an ecommerce webpage. I would like to hide products that do not have images from the carousel. I am very new to all of this. It is my first webpage ever, and I have limited programming knowledge - but I'm willing to learn.
From what I have found so far, there is a filter hook for product item wrapper class. You can access product id from $args
variable like $product_id = $args['product_id'];
Then you should be able to conditionally add a hidden class to item wrapper by checking if a product image exists or not.
This is what I have tried without success (php):
add_filter('wcps_slider_item_class','wcps_slider_item_class_20200303', 10, 2);
function wcps_slider_item_class_20200303($class, $args){
$product_id = isset($args['product_id']) ? $args[‘product_id’] : '';
$class .= ' my-custom-class';
if ($product_id->get_image() && $product_id->get_image() == 'no_selection') {
$class =' .hidden {
display: none;';
}
return $class;
}
If anyone can help it is greatly appreciated.
本文标签: phpHow to hide products that do not have an image from a slider carousel for an ecommerce webpage
版权声明:本文标题:php - How to hide products that do not have an image from a slider carousel for an ecommerce webpage? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741820875a2399356.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论