Advertisement
FireBot

woocommerce-custom-variation-fields-variable-php

Nov 19th, 2014
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.64 KB | None | 0 0
  1. <?php
  2. // get the post IDs of all the product variations
  3. $variation_ids = $product->children;
  4.  
  5. foreach( $variation_ids as $var_id ) :
  6.    
  7.     // get the data from the custom fields
  8.     $color_hex = get_post_meta( $var_id, 'color_hex', true ); // does this product have an alternate buying option?
  9.    
  10.     // model-(attribute value)
  11.     $model_name = 'model-'.get_post_meta($var_id, 'attribute_model', true);
  12.     ?>
  13.    
  14.     <div class="custom_variation" id ="<?php echo $model_name; ?>">
  15.         <div class="variations_button">
  16.             <?php echo $color_hex ?>
  17.         </div>
  18.     </div><!-- #custom_variation -->
  19.  
  20. <?php endforeach; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement