Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress 编辑elementor菜单车_Wordpress_Menu_Cart_Elementor - Fatal编程技术网

Wordpress 编辑elementor菜单车

Wordpress 编辑elementor菜单车,wordpress,menu,cart,elementor,Wordpress,Menu,Cart,Elementor,我有一个wordpress网站,我正在使用Elementor。我使用“菜单购物车”来显示购物车内容。 现在我正试图删除购物车上的“删除项目图标”(产品旁边的小十字架)。但如果我通过设置禁用它,它将被所有产品删除。相反,我只想删除一个项目 任何建议都会有帮助好的,因此您需要添加带有woocommerce\u cart\u item\u remove\u链接的过滤器 function disable_remove_for_sim_card( $cart_item_key, $button_lin

我有一个wordpress网站,我正在使用Elementor。我使用“菜单购物车”来显示购物车内容。

现在我正试图删除购物车上的“删除项目图标”(产品旁边的小十字架)。但如果我通过设置禁用它,它将被所有产品删除。相反,我只想删除一个项目


任何建议都会有帮助

好的,因此您需要添加带有woocommerce\u cart\u item\u remove\u链接的过滤器

function disable_remove_for_sim_card( $cart_item_key, $button_link ){
    $product_id = 'ID'; //your product ID here
    $cart_item = WC()->cart->get_cart()[$cart_item_key];
    
    if( in_array($cart_item['data']->get_id(), $product_id) )
        $button_link = '';

    return $button_link;
}
add_filter('woocommerce_cart_item_remove_link', 'disable_remove_for_sim_card');

禁用elementors微型购物车按钮的方法可能是在购物车项目的ID位于数组中时,在购物车项目中设置一个额外的类,并添加一些css类来隐藏它。

所以您只想在一个产品中删除它?我的要求是不能删除一个特定的产品。如果您在第二个屏幕截图中看到,我已标记了要删除其“删除图标”的元素。例如,我们有类别1和类别2。因此,如果用户在购物车中同时添加类别1和类别2,则用户应该无法删除类别2。作为一个快速解决方案,我有代码将禁用产品从购物车中删除,但不禁用图标。对于图标,它需要更长的时间。我想那应该行得通。我可以从中得到一些想法,也可以即兴创作图标。试试我的答案,让我知道它是否对你有帮助