WooCommerce IF statements not working
The solution to my problem was to use: has_term( ‘the-cat-I-want-to-display’, ‘product_cat’ ) || is_product_category( ‘the-cat-I-want-to-display’ ) This worked. Thanks everyone for your help!
The solution to my problem was to use: has_term( ‘the-cat-I-want-to-display’, ‘product_cat’ ) || is_product_category( ‘the-cat-I-want-to-display’ ) This worked. Thanks everyone for your help!
To answer your second question you’ll have to properly enqueue the Bootstrap 4 styles and scripts: Including CSS & JavaScript | Theme Development From there you either have to add existing WooCommerce classes to your BootStrap CSS or add BootStrap classes to your WooCommerce templates (preferred/recommended). As for the templates, it really depends on which … Read more
You can try adding this in your functions.php file: add_action(‘admin_head’, ‘hide_delete_note_from_edit_order’); function hide_delete_note_from_edit_order() { $screen = get_current_screen(); if ($screen->post_type === “shop_order” && $screen->base === “post”) { echo ‘<style>a.delete_note { display:none; }</style>’; } }
function change_admin_email_subject( $subject, $order ) { // Get items $items = $order->get_items(); foreach ( $items as $item ) { // Get product object $product = wc_get_product( $item[‘product_id’] ); // Get product id $product_id = $product->get_id(); if ( $product_id == 153 ) { $subject=”¡Bienvenida al Curso Online 4″; } elseif ( $product_id == 192 ) { … Read more
You can’t with woocommerce_get_product_thumbnail(), but this will give you the exact same result: global $product; $image_size = apply_filters( ‘single_product_archive_thumbnail_size’, ‘woocommerce_thumbnail’ ); $custom_alt=”Put your custom alt text here.”; return $product ? $product->get_image( $image_size, [ ‘alt’ => $custom_alt ] ) : ”;
This requires to use an action hook like woocommerce_calculate_totals that is related to cart and Ajax enabled, because it will handle all changes made by the customer in cart page: add_action( ‘woocommerce_calculate_totals’, ‘discount_based_on_cart_subtotal’, 10, 1 ); function discount_based_on_cart_subtotal( $cart ) { if ( is_admin() && ! defined( ‘DOING_AJAX’ ) ) return; // Avoiding hook repetitions … Read more
I literally did this same thing this morning. Here’s a function that you can use. You can add the function to your functions.php (or wherever) and then call the function on your template: /** * @param array $product_ids product_id the product id for the product you want to retrieve. * * @return string the HTML … Read more
Here shows only the loop parts of the code Since I don’t know what is the data structure of $session_data. I suppose $session_data[$key] return a product name first in order to create the example. Because you are creating a custom email, I assume HTML email is supported. // examples to show how to correctly loop … Read more
add_action( ‘woocommerce_before_calculate_totals’, ‘change_subscription_signup_fee’, 1000, 1 ); function change_subscription_signup_fee( $cart ) { if (is_admin() && !defined(‘DOING_AJAX’)) return; if ( did_action( ‘woocommerce_before_calculate_totals’ ) >= 2 ) return; // Loop through cart items foreach ( $cart->get_cart() as $cart_item ) { // Check that product custom cart item data “alredy_have_number” exist and is true if( isset($cart_item[‘alredy_have_number’]) && $cart_item[‘alredy_have_number’] ) … Read more
This will check to see if there is a hierarchy and set all parent categories as checked. This function assumes that if there’s multiple categories already set, then don’t do the function, since the categories would be correct if multiples are set. function set_product_parent_categories( $post_id ) { $category = wp_get_post_terms( $post_id, ‘product_cat’ ); // If … Read more