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

How to unhook a function in Woocommerce Template?

You need to unhook the function from that action specifically: remove_action( ‘woocommerce_review_before_comment_meta’, ‘woocommerce_review_display_rating’, 10 ); (e.g. look for the opposite add_action() line in includes/wc-template-hooks.php) You’ll also need to make sure that this is run after WooCommerce has loaded and added the action you’re about to remove, e.g. place this in a plugins_loaded hook: function unhook_display_rating() … Read more

Auto update cart after quantity change

Almost one year late, but this question might still get visitors: You trigger the click, but the button doesn’t have enough time to become enabled, so that is why, by the time you click the second time the button becomes enabled. Remove the “disabled” propriety before triggering the click: <script> jQuery(‘div.woocommerce’).on(‘change’, ‘.qty’, function(){ jQuery(“[name=”update_cart”]”).prop(“disabled”, false); … Read more

How to add multiple product gallery images from front-end

if ( ! empty( $_FILES[‘muti_files’] ) ) { $files = $_FILES[‘muti_files’]; foreach ($files[‘name’] as $key => $value){ if ($files[‘name’][$key]){ $file = array( ‘name’ => $files[‘name’][$key], ‘type’ => $files[‘type’][$key], ‘tmp_name’ => $files[‘tmp_name’][$key], ‘error’ => $files[‘error’][$key], ‘size’ => $files[‘size’][$key] ); } $_FILES = array(“muti_files” => $file); $i=1; foreach ($_FILES as $file => $array) { if ($_FILES[$file][‘error’] !== … Read more

Change font size in products listing pages in woocommerce

Another option would be to use the current_screen hook add_action( ‘current_screen’, ‘my_admin_listing_custom_styles’ ); function my_admin_listing_custom_styles() { $current_screen = get_current_screen(); if( ‘edit’ == $current_screen->base && ‘product’ == $current_screen->post_type) { // Run some code, only on the admin products listing page for e.x add css style ?> <style type=”text/css”> a.row-title {font-size: 18px !important;} </style> <?php } }