Posts

Showing posts with the label woocommerce

How to add a class to a WooCommerce product within the product loop

How to add a class to a WooCommerce product within the product loop I would like to add multiple bootstrap col classes to this line of code inside the product loop but I have no idea. <li><?php wc_product_class(); ?></li> Can I somehow push my classed into this bit of php and still keep the product applied? 2 Answers 2 try this <li <?php wc_product_class("col-md-4 col-sm-6 custom-class m-4"); ?>></li> <li <?php wc_product_class("col-md-4 col-sm-6 custom-class m-4"); ?>></li> For this wc_product_class(); uses two arguments one is class name and other one is product id so just pass your class name as first argument and product id in second one. wc_product_class(); you could see the wc_product_class() in /woocommerce/includes/wc-template-functions.php For example your class name is test and product id is 143 then just pass ...

How to un-hide the coupon in Woocommerce checkout page

How to un-hide the coupon in Woocommerce checkout page There is a link right under the checkout header on Woocommerce that says "Click here to enter your code". When you click it, a javascript slides the billing details box down to show the coupon code box and "apply coupon" button. I am trying to make this show automatically on the page load. The other option is to change the javascript from a click action to a page load action. 1 Answer 1 Write in your custom CSS: .checkout_coupon { display: block !important; } .woocommerce-info { display:none; } By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

How to group woocommerce products by category in WordPress

Image
How to group woocommerce products by category in WordPress I have at least 4 Parent Categories and each parent category has a sub-category. The categories in WordPress looks like this: Lidingö (Parent Category) Nacka (Parent Category) I want to query the products in WordPress and they should be grouped by categories. This is my current code: <?php $args = array( 'post_type' => 'product', array( 'taxonomy' => 'product_cat' ), 'posts_per_page' => 6, ); $loop = new WP_Query( $args ); if ( $loop->have_posts() ) { while ( $loop->have_posts() ) : $loop->the_post(); echo woocommerce_template_single_title(); endwhile; } else { echo __( 'No products found' ); } wp_reset_postdata(); ?> I think the code above is not correct because the same products are being displayed for every pagination. Do you have any idea what is ...

Adding custom variation field data to CSV order export - WooCommerce

Adding custom variation field data to CSV order export - WooCommerce I have been searching everywhere for an answer and just keep hitting road block after road block I have added custom variations fields in WooCommerce using http://www.remicorson.com/woocommerce-custom-fields-for-variations/ These fields save correctly when updating products. I have installed WooCommerce Customer / Order CSV Export and have added a meta_field column placing the meta_key found in the code below. Screenshot of the fields However when I export the CSV file the fields are empty. Anyone have any experience with getting the custom variation field data to appear when exporting order data via CSV. Listed below is the custom variation code being used. Any guidance would be greatly appreciated. /** * Create new fields for variations * */ function variation_settings_fields( $loop, $variation_data, $variation ) { // Text Field woocommerce_wp_text_input( array( 'id' ...

Using Product CRUD setter methods in Woocommerce 3

Using Product CRUD setter methods in Woocommerce 3 In the code bellow, I can't set some product category and product tags: The code is located in my functions.php file: <?php $product = new WC_Product; $product->set_name("product"); $product->set_regular_price('150'); $set_cat = $product->set_category_ids( array(17) ); $set_tag = $product->set_tag_ids( [18, 19] ); $product->save(); var_dump($set_cat);//NULL var_dump($set_tag);//NULL The product is created with the correct name and price . But I get nothing for the product category and product tags: name price terms: [terms table][1] term_taxonomy: [term_taxonomy table][2] Edit: I have moved this code in index.php file and It works. index.php Could you add a bit more clarification to this question, what exactly are you trying to do and what aspect of it is not working, have you tried anything else to address the issue? – David Rogers ...