0 ) { add_meta_box( 'al_product_attributes', $labels[ 'attributes' ], 'al_product_attributes', 'al_product', apply_filters( 'product_attributes_box_column', 'normal' ), apply_filters( 'product_attributes_box_priority', 'default' ) ); } } /** * Shows attributes metabox * * @global type $post */ function al_product_attributes() { global $post; echo ''; echo '
' . __( 'Only attributes with values set will be shown on product page.', 'ecommerce-product-catalog' ) . ' ' . sprintf( __( 'See docs.', 'ecommerce-product-catalog' ), 'https://implecode.com/docs/ecommerce-product-catalog/product-attributes/?cam=catalog-add-page-box&key=product-attributes' ) . '
'; do_action( 'before_product_attributes_edit_single' ); echo ''; do_action( 'inside_attributes_edit_table' ); $attributes_option = get_option( 'product_attribute' ); $attributes_label_option = get_option( 'product_attribute_label' ); $attributes_unit_option = get_option( 'product_attribute_unit' ); $attributes_number = product_attributes_number(); $available_labels = get_all_attribute_labels(); $label_autocomplete = ''; if ( !empty( $available_labels ) ) { $label_autocomplete = 'data-ic-autocomplete="' . esc_attr( json_encode( $available_labels ) ) . '"'; } for ( $i = 1; $i <= $attributes_number; $i++ ) { $attributes_option_field = get_attribute_value( $i, $post->ID ); //get_post_meta( $post->ID, '_attribute' . $i, true ); $attributes_label_option_field = get_attribute_label( $i, $post->ID ); //get_post_meta( $post->ID, '_attribute-label' . $i, true ); $attributes_unit_option_field = get_attribute_unit( $i, $post->ID ); //get_post_meta( $post->ID, '_attribute-unit' . $i, true ); $attributes_option[ $i ] = isset( $attributes_option[ $i ] ) ? $attributes_option[ $i ] : ''; $attributes_label_option[ $i ] = isset( $attributes_label_option[ $i ] ) ? $attributes_label_option[ $i ] : ''; $attributes_unit_option[ $i ] = isset( $attributes_unit_option[ $i ] ) ? $attributes_unit_option[ $i ] : ''; if ( is_ic_new_product_screen() ) { $attributes_option_field = !empty( $attributes_option_field ) ? $attributes_option_field : $attributes_option[ $i ]; } $attributes_label_option_field = !empty( $attributes_label_option_field ) ? $attributes_label_option_field : $attributes_label_option[ $i ]; $attributes_unit_option_field = !empty( $attributes_unit_option_field ) ? $attributes_unit_option_field : $attributes_unit_option[ $i ]; $attribute_value_field = ''; if ( is_array( $attributes_option_field ) ) { $attributes_option_field = ''; } $autocomplete = ''; if ( !empty( $attributes_label_option_field ) ) { $available_attribute_values = ic_get_attribute_values( $attributes_label_option_field ); if ( $available_attribute_values ) { $autocomplete = 'data-ic-autocomplete="' . esc_attr( json_encode( $available_attribute_values ) ) . '"'; } } $attribute_value_field = ''; ?>
Name Value Unit
class="ic_autocomplete attribute-label" type="text" name="_attribute-label" value=""/> :
ID ) : ''; $product_meta[ '_attribute' . $i ] = !empty( $_POST[ '_attribute' . $i ] ) ? apply_filters( 'save_product_attribute_value', $_POST[ '_attribute' . $i ], $i, $post->ID, $product_meta[ '_attribute-label' . $i ] ) : ''; $product_meta[ '_attribute-unit' . $i ] = !empty( $_POST[ '_attribute-unit' . $i ] ) ? apply_filters( 'save_product_attribute_unit', $_POST[ '_attribute-unit' . $i ], $i, $post->ID, $product_meta[ '_attribute-label' . $i ] ) : ''; } return $product_meta; }