Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class WC_Swatch_Picker {
- private $size;
- private $attributes;
- private $selected_attributes;
- private $swatch_type_options;
- public function __construct( $product_id, $attributes, $selected_attributes ) {
- $this->swatch_type_options = maybe_unserialize( get_post_meta( $product_id, '_swatch_type_options', true ) );
- if ( !$this->swatch_type_options ) {
- $this->swatch_type_options = array();
- }
- $product_configured_size = get_post_meta( $product_id, '_swatch_size', true );
- if ( !$product_configured_size ) {
- $this->size = 'swatches_image_size';
- } else {
- $this->size = $product_configured_size;
- }
- $this->attributes = $attributes;
- $this->selected_attributes = $selected_attributes;
- }
- public function picker() {
- ?>
- <table class="variations-table" cellspacing="0">
- <tbody>
- <?php
- $loop = 0;
- foreach ( $this->attributes as $name => $options ) : $loop++;
- $st_name = sanitize_title( $name );
- $hashed_name = md5( $st_name );
- $lookup_name = '';
- if ( isset( $this->swatch_type_options[$hashed_name] ) ) {
- $lookup_name = $hashed_name;
- } elseif ( isset( $this->swatch_type_options[$st_name] ) ) {
- $lookup_name = $st_name;
- }
- ?>
- <tr>
- <td class="label"><label for="<?php echo $st_name; ?>"><?php echo WC_Swatches_Compatibility::wc_attribute_label( $name ); ?></label></td>
- <td>
- <?php
- if ( isset( $this->swatch_type_options[$lookup_name] ) ) {
- $picker_type = $this->swatch_type_options[$lookup_name]['type'];
- if ( $picker_type == 'default' ) {
- $this->render_default( $st_name, $options );
- } else {
- $this->render_picker( $st_name, $options, $name );
- }
- } else {
- $this->render_default( $st_name, $options );
- }
- ?>
- </td>
- </tr>
- <?php endforeach; ?>
- </tbody>
- </table>
- <?php
- }
- //More public_funtions here....
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement