<?php

if ( !defined('ABSPATH') ) exit;

add_filter( 'woocommerce_add_to_cart_redirect', 'bbloomer_redirect_checkout_add_cart' );
 
function bbloomer_redirect_checkout_add_cart() {
   return wc_get_checkout_url();
}

/* trim zeros on decimal price */
add_filter( 'woocommerce_price_trim_zeros', '__return_true' );

add_action('wp_head', 'inline_custom_checkout_styles');

function inline_custom_checkout_styles() {
    // Check if the product with ID 990242 is in the cart
    if (is_product_in_cart(990242) && is_checkout()) {
        ?>
        <style type="text/css">
            #pisol-pickup-locations .pisol-pickup-add:first-child {
				display:none
			}
        </style>
        <?php
    }
}

// Helper function to check if a product is in the cart
function is_product_in_cart($product_id) {
    // Loop through cart items
    foreach (WC()->cart->get_cart() as $cart_item) {
        // Check if the product ID is in the cart
        if ($cart_item['product_id'] == $product_id) {
            return true;
        }
    }
    return false;
}
