Remove Prices on products and change checkout process
-
Hi everyone, I am new to WordPress and I am working on a site for my employer. I am trying to create a website where it’s used more like a catalog. Since we are a wholesaler, we don’t want to display prices, and instead of checkout we want the option to email the cart contents to our sales rep.
Is there a way to do this without paying for a plugin? Currently I’m using the Change Price Title for WooCommerce plugin, but when I go into the cart, I can still see the prices that I was forced to add via Woocommerce.
Additionally, when I am in the cart, I would like to change the checkout process, to email the cart contents rather than having to enter billing information, etc. I’m not sure if this is possible. I come from Shopify and they didn’t let you change this outside of the Plus plan, so I’m guessing it’s something similar? Any help would be appreciated.
-
Hi @bandngotester,
Welcome to the WordPress community!
Matching your specific requirements with free plugins can be quite challenging, and you might not find a perfect solution. In this case, a custom code solution is likely the best approach. Here’s how you can achieve your goals: Hiding PricesHide Prices with CSS: Since you’re using the Change Price Title for the WooCommerce plugin but still seeing prices in the cart, you can add custom CSS to hide the prices from the cart and product pages.
Add the following CSS code to your theme’sstyle.cssfile or in the Customizer under Additional CSS:.woocommerce-Price-amount, .amount { display: none; }Custom Functions to Remove Prices: If the CSS method doesn’t fully hide the prices, you can add custom PHP functions to your theme’s
functions.phpfile to remove prices from the cart page.// Remove prices from cart and checkoutadd_filter( 'woocommerce_cart_item_price', '__return_false' ); add_filter( 'woocommerce_cart_item_subtotal', '__return_false' );Email Cart Contents Instead of Checkout
Override the Checkout Process: To replace the checkout process with an email option, you can customize WooCommerce to send the cart contents via email. Here is a basic example to get you started:
// Add a custom email cart button function add_email_cart_button() { echo '<a href="' . esc_url( wc_get_cart_url() ) . '?email_cart=true" class="button">Email Cart</a>'; } add_action( 'woocommerce_proceed_to_checkout', 'add_email_cart_button', 20 ); // Handle the email cart request function handle_email_cart_request() { if ( isset( $_GET['email_cart'] ) ) { $cart = WC()->cart->get_cart(); $items = ''; foreach ( $cart as $cart_item_key => $cart_item ) { $product = $cart_item['data']; $items .= $product->get_name() . ' - Quantity: ' . $cart_item['quantity'] . "n"; } $to = '(email visible only to moderators and staff)'; // Replace with your sales rep's email $subject = 'New Cart Submission'; $message = 'The following items were submitted from the cart:' . "nn" . $items; wp_mail( $to, $subject, $message ); wc_add_notice( 'Your cart has been emailed to our sales representative.', 'success' ); } } add_action( 'template_redirect', 'handle_email_cart_request' );This code adds an “Email Cart” button on the cart page and sends the cart contents to a specified email address when clicked. Be sure to replace
(email visible only to moderators and staff)with your actual sales rep’s email address.// Remove billing fields add_filter( 'woocommerce_checkout_fields', 'custom_remove_billing_fields' ); function custom_remove_billing_fields( $fields ) { unset( $fields['billing']['billing_first_name'] ); unset( $fields['billing']['billing_last_name'] ); unset( $fields['billing']['billing_company'] ); unset( $fields['billing']['billing_address_1'] ); unset( $fields['billing']['billing_address_2'] ); unset( $fields['billing']['billing_city'] ); unset( $fields['billing']['billing_postcode'] ); unset( $fields['billing']['billing_country'] ); unset( $fields['billing']['billing_state'] ); unset( $fields['billing']['billing_phone'] ); unset( $fields['billing']['billing_email'] ); return $fields; }I hope this helps! Let us know if you have any further questions.
Best regards,
- The topic ‘Remove Prices on products and change checkout process’ is closed to new replies.