I am trying to edit some PHP code so that the cart appears on the checkout page for certain users only. I need it to appear for guests, customers, and admins. I know very little about PHP, but the code is throwing an error.
This is the original code I started with, and wanted to add an if statement so it shows up for certain users only:
add_action( 'woocommerce_before_checkout_form', 'bbloomer_cart_on_checkout_page_only', 5 );
function bbloomer_cart_on_checkout_page_only() {
if ( is_wc_endpoint_url( 'order-received' ) ) return;
echo do_shortcode('[woocommerce_cart]');
}
This is the code I am trying that is not working:
add_action( 'woocommerce_before_checkout_form', 'bbloomer_cart_on_checkout_page_only', 5 );
function bbloomer_cart_on_checkout_page_only() {
if ( Auth::guest() && current_user_can('customer') || current_user_can('Administrator' ) && is_wc_endpoint_url( 'order-received' ) ) return;
echo do_shortcode('[woocommerce_cart]');
}
Aucun commentaire:
Enregistrer un commentaire