echo product id and product_item_key in cart [closed]

Techno Deviser, probably by mistake, in the foreach loop set value to $fragments[‘div.header-cart-count’] instead append it. Try this modification: function iconic_cart_count_fragments( $fragments ) { foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { $fragments[‘div.header-cart-count’] .= ‘<div class=”header-cart-count”>’ .$cart_item_key.'<br><br>’. $cart_item[‘product_id’]. ‘</div>’; } return $fragments; } Or: function iconic_cart_count_fragments( $fragments ) { $cart = WC()->cart->get_cart(); if (!empty($cart)) … Read more

Does the woocommerce_order_status_changed hook fire when WooCommerce updates an order status automatically? [closed]

One of the results did bring up this (in reference to woocommerce_order_status_changed): “Where the hook is used (in WC core): Does not used.” Which seems to answer Question 1, which is what leads me to believe if WooCommerce or a payment gateway changes the order status automatically, it will never fire, thus not creating our … Read more

Unhook action from child theme

I eventually figured this out, I don’t know exactly why, but it seems the issue was due to the original use of init, once i replaced it with ‘wp_head’ it worked correctly, my final code looked like this function change_default_galleria_header() { remove_action( ‘storefront_header’, ‘storefront_header_cart’, 4 ); remove_action( ‘storefront_header’, ‘storefront_product_search’, 3 ); remove_action( ‘storefront_header’, ‘storefront_secondary_navigation’, 6 … Read more

WooCommerce: Email Notifications

You may be using the wrong hook. I use this : add_action( “woocommerce_email_after_order_table”, “custom_woocommerce_email_after_order_table”, 10, 1); function custom_woocommerce_email_after_order_table( $order ) { echo ‘<p>content after email table</p>’; } now, if you look at this link it will show you other hooks that you can use if you want to append other information to the email. for … Read more

How to get all attributes with their terms related to specific Woocommerce product category [closed]

Well, I found the following solution: $args = array( ‘category’ => array( ‘category_slug’ ) // or ‘term_taxonomy_id’ => 4 i.e. category ID ); foreach( wc_get_products($args) as $product ){ foreach( $product->get_attributes() as $attr_name => $attr ){ echo wc_attribute_label( $attr_name ); // attr label // or get_taxonomy( $attr_name )->labels->singular_name; foreach( $attr->get_terms() as $term ){ echo $term->name; } … Read more

WooCommerce checkout: How can I change $field_container of a checkout field?

The woocommerce_form_field() is a pluggable function, defined as follows: if ( ! function_exists( ‘woocommerce_form_field’ ) ) { /** * Outputs a checkout/address form field. * * @param string $key Key. * @param mixed $args Arguments. * @param string $value (default: null). * @return string */ function woocommerce_form_field( $key, $args, $value = null ) { … … Read more