woo add to cart – display price in button with text according to category

add_filter( 'woocommerce_product_add_to_cart_text', 'custom_add_to_cart_price', 20, 2 ); // Shop and other archives pages
add_filter( 'woocommerce_product_single_add_to_cart_text', 'custom_add_to_cart_price', 20, 2 ); // Single product pages

function custom_add_to_cart_price( $button_text, $product ) {
    // Check if the product belongs to a specific category (e.g., 'tickets' or 'camping')
    $categories = array( 'tickets', 'camping' );

    if ( has_term( $categories, 'product_cat', $product->get_id() ) ) {
        $product_price = wc_price( wc_get_price_to_display( $product ) );
        return  strip_tags( $product_price ) . ' Per Person';
    } elseif( $product->is_type('variable') ) {
        // For variable products
        if( ! is_product() ){
            $product_price = wc_price( wc_get_price_to_display( $product, array( 'price' => $product->get_variation_price() ) ) );
            return $button_text . ' - From ' . strip_tags( $product_price );
        } 
        // Single product pages
        else {
            return $button_text;
        }
    } else {
        // For all other product types
        $product_price = wc_price( wc_get_price_to_display( $product ) );
        return  strip_tags( $product_price );
    }
}

woocommerce button color control

.woocommerce #content input.button.alt:hover, .woocommerce #respond input#submit.alt:hover, .woocommerce a.button.alt:hover, .woocommerce button.button.alt:hover, .woocommerce input.button.alt:hover, .woocommerce-page #content input.button.alt:hover, .woocommerce-page #respond input#submit.alt:hover, .woocommerce-page a.button.alt:hover, .woocommerce-page button.button.alt:hover, .woocommerce-page input.button.alt:hover {
background:#126b11;
background-color:#126b11;
color:white !important;
text-shadow: transparent !important;
box-shadow: none;
border-color:#126b11 !important;

}
.woocommerce #content input.button:hover, .woocommerce #respond input#submit:hover, .woocommerce a.button:hover, .woocommerce button.button:hover, .woocommerce input.button:hover, .woocommerce-page #content input.button:hover, .woocommerce-page #respond input#submit:hover, .woocommerce-page a.button:hover, .woocommerce-page button.button:hover, .woocommerce-page input.button:hover {
background:#126b11;
background-color:#126b11;
color:white !important;
text-shadow: transparent !important;
box-shadow: none;
border-color:#126b11 !important;

}
.woocommerce #content input.button, .woocommerce #respond input#submit, .woocommerce a.button, .woocommerce button.button, .woocommerce input.button, .woocommerce-page #content input.button, .woocommerce-page #respond input#submit, .woocommerce-page a.button, .woocommerce-page button.button, .woocommerce-page input.button {
background: #126b11 !important;
color:white !important;
text-shadow: transparent !important;
border-color:#126b11 !important;
}

.woocommerce #content input.button.alt:hover, .woocommerce #respond input#submit.alt:hover, .woocommerce a.button.alt:hover, .woocommerce button.button.alt:hover, .woocommerce input.button.alt:hover, .woocommerce-page #content input.button.alt:hover, .woocommerce-page #respond input#submit.alt:hover, .woocommerce-page a.button.alt:hover, .woocommerce-page button.button.alt:hover, .woocommerce-page input.button.alt:hover {
background: #126b11 !important;
box-shadow: none;
text-shadow: transparent !important;
color:white !important;
border-color:#126b11;
}

woocommerce – custom function to override default sort by category

// woo - custom function to override default sort by category
function custom_default_catalog_orderby() {
//choose categories where default sorting will be changed
if (is_product_category( array( 'seasonal' ))) {
    return 'title'; // sort by title
    
}else{
return 'date'; // sort by date as the default
    
  } // end if statement
} //end function
add_filter( 'woocommerce_default_catalog_orderby', 'custom_default_catalog_orderby' ); //add the filter

woo omit categories from shop

// woo - omit categories from shop page

add_filter( 'get_terms', 'ts_get_subcategory_terms', 10, 3 );
function ts_get_subcategory_terms( $terms, $taxonomies, $args ) {
$new_terms = array();
// if it is a product category and on the shop page
if ( in_array( 'product_cat', $taxonomies ) && ! is_admin() &&is_shop() ) {
foreach( $terms as $key => $term ) {
if ( !in_array( $term->slug, array( 'uncategorized', 'sessions', 'programs' ) ) ) { //pass the slug name here
$new_terms[] = $term;
}}
$terms = $new_terms;
}
return $terms;
}

woo autocomplete virtual orders

/**
 * Auto Complete all WooCommerce virtual orders.
 * 
 * @param  int 	$order_id The order ID to check
 * @return void
 */
function custom_woocommerce_auto_complete_virtual_orders( $order_id ) {

	// if there is no order id, exit
	if ( ! $order_id ) {
		return;
	}

	// get the order and its exit
	$order = wc_get_order( $order_id );
	$items = $order->get_items();

	// if there are no items, exit
	if ( 0 >= count( $items ) ) {
		return;
	}

	// go through each item
	foreach ( $items as $item ) {

		// if it is a variation
		if ( '0' != $item['variation_id'] ) {

			// make a product based upon variation
			$product = new WC_Product( $item['variation_id'] );

		} else {

			// else make a product off of the product id
			$product = new WC_Product( $item['product_id'] );

		}

		// if the product isn't virtual, exit
		if ( ! $product->is_virtual() ) {
			return;
		}
	}

	/*
	 * If we made it this far, then all of our items are virual
	 * We set the order to completed.
	 */
	$order->update_status( 'completed' );
}
add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_virtual_orders' );

woo product title above image

// woo - product title above image
function product_change_title_position() {
	remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
	add_action( 'woocommerce_before_single_product', 'woocommerce_template_single_title', 5 );
}
add_action( 'init', 'product_change_title_position' );

woo remove tabs on product page

//Remove WooCommerce Tabs - this code removes all 3 tabs - to be more specific just remove actual unset lines 
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
function woo_remove_product_tabs( $tabs ) {

    unset( $tabs['description'] );      	// Remove the description tab
    unset( $tabs['reviews'] ); 			// Remove the reviews tab
    unset( $tabs['additional_information'] );  	// Remove the additional information tab
    
    return $tabs;

}