ADD SAMPLE TO MULTIPLE PRODUCTS workaround
-
Here is a little loop to add the sample option to multiple products
This will set the sample price to 0.50
Please note, if you set a category with a lot of products this may break the internet<?php $args = array( 'product_cat' => 'your-cateogry-name-here', 'post_type' => 'product','posts_per_page' => '-1' ); $postslist = get_posts( $args ); foreach ($postslist as $post) : setup_postdata($post); ?> <?php add_post_meta( $post->ID, 'sample_enamble', "1" ); ?> <?php add_post_meta( $post->ID, 'sample_price_mode', "default" ); ?> <?php add_post_meta( $post->ID, 'sample_price', "0.5" ); ?> <?php add_post_meta( $post->ID, 'sample_shipping_mode', "default" ); ?> <?php endforeach; ?>
- The topic ‘ADD SAMPLE TO MULTIPLE PRODUCTS workaround’ is closed to new replies.