Woocommerce Product Table Plugin Custom button & add to cart link

I recently purchased the Woocommerce product table from barn2, and started working with it.

I managed to hide the price for logged out users and change the text of the add-to-cart button but I am looking to change the functionality as well!

I unfortunately could not find any helpful information in the docs of the plugin.

I am looking to replace the url of the add to card button when users are logged out.
I am looking to add a custom button to the price field when users are logged out.

Current code:

// change add to cart button text
function hide_cart_button_logged_out($text) {
if ( !is_user_logged_in() ) {
return ‘Inloggen’;
}
return $text;
}

add_filter( ‘add_to_cart_text’, ‘hide_cart_button_logged_out’, 999 );
add_filter( ‘woocommerce_product_single_add_to_cart_text’,
‘hide_cart_button_logged_out’, 999 )

// hide cart if user is logged out

function hide_cart_logged_out(){
if ( !is_user_logged_in() ) {
remove_action(‘storefront_header’, ‘storefront_header_cart’, 60);
}
}
add_action( ‘storefront_header’, ‘hide_cart_logged_out’, 1);

// hide price if user is logged out table

function hide_price_logged_out( $price ) {
if ( !is_user_logged_in() ) {
return ‘Log in voor prijzen’;
}
return $price;
}
add_filter( ‘wc_product_table_data_price’, ‘hide_price_logged_out’ );

Read more here:: Woocommerce Product Table Plugin Custom button & add to cart link

Leave a Reply

Your email address will not be published. Required fields are marked *