Woocommerce Add prices

If you need to be able to add or remove an amount from standard prices at any time, you could add a custom field to WooCommerce’s settings pages, then modify the price of your products using the built-in filter. Here is how I would do it: (this would go in your theme’s functions.php file) /** … Read more

Working with a json feed & trying to figure out how best to import

You could use a combination of update_post_meta(), set_objetc_terms(), and wp_update_post() to update your products. It is a good idea to use taxonomies (product categories and product attributes in WooC) as extensively as possible to store common product data as it makes searching for products faster compared to storing the data in post_meta. Here’s a concept … Read more

Display Products Associated with Specific Attribute [closed]

Error in wc_get_products caught by @SallyCJ fixed my problem. Where I had ingredients, I needed pa_ingredients. Working code is as follows: $taxonomy = ‘pa_ingredients’; $terms = get_terms( $taxonomy ); foreach ( $terms as $term ) { $products = wc_get_products( array( ‘pa_ingredients’ => $term->slug ) ); foreach ( $products as $product ) { $product_id = wc_get_product_id_by_sku( … Read more

Make WooCommerce product categories only show images on homepage

Try running your function hooked into the template_redirect action like so: <?php function fp_categories() { if( is_front_page() ) { add_action( ‘woocommerce_before_subcategory_title’, ‘woocommerce_subcategory_thumbnail’, 10 ) ; } else { remove_action( ‘woocommerce_before_subcategory_title’, ‘woocommerce_subcategory_thumbnail’, 10 ) ; } } add_action( ‘template_redirect’, ‘fp_categories’ ); ?> I’m fuzzy on the logic why this works – I believe otherwise the functions … Read more

Checkbox field that add a subscription product and change prices of other products in checkout and cart page

I solved the my issue. this code may help others in future. // Display a custom checkout field add_action( ‘woocommerce_checkout_before_terms_and_conditions’, ‘custom_checkbox_checkout_field’ ); function custom_checkbox_checkout_field() { $value = WC()->session->get(‘add_a_product’); woocommerce_form_field( ‘cb_add_product’, array( ‘type’ => ‘checkbox’, ‘label’ => ‘&nbsp;&nbsp;’ . __(‘Please check here to get VIP Membership’), ‘class’ => array(‘form-row-wide’), ), $value == ‘yes’ ? true : … Read more