html-order-download-permission.php
6 years ago
html-order-fee.php
5 months ago
html-order-item-meta.php
1 month ago
html-order-item.php
1 month ago
html-order-items.php
2 weeks ago
html-order-notes.php
2 months ago
html-order-refund.php
5 months ago
html-order-shipping.php
2 weeks ago
html-product-attribute-inner.php
1 month ago
html-product-attribute.php
1 month ago
html-product-data-advanced.php
1 month ago
html-product-data-attributes.php
1 week ago
html-product-data-general.php
3 months ago
html-product-data-inventory.php
6 months ago
html-product-data-linked-products.php
4 months ago
html-product-data-panel.php
2 years ago
html-product-data-shipping.php
3 years ago
html-product-data-variations.php
1 week ago
html-product-download.php
6 months ago
html-product-variation-download.php
6 months ago
html-variation-admin.php
2 months ago
html-product-attribute-inner.php
153 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Product attribute table for reuse. |
| 4 | * |
| 5 | * @package WooCommerce\Admin |
| 6 | */ |
| 7 | |
| 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | exit; |
| 10 | } |
| 11 | |
| 12 | use Automattic\WooCommerce\Internal\ProductAttributes\VisualAttributeTermMeta; |
| 13 | ?> |
| 14 | |
| 15 | <table cellpadding="0" cellspacing="0"> |
| 16 | <tbody> |
| 17 | <tr> |
| 18 | <td class="attribute_name"> |
| 19 | <label><?php esc_html_e( 'Name', 'woocommerce' ); ?>:</label> |
| 20 | |
| 21 | <?php if ( $attribute->is_taxonomy() ) : ?> |
| 22 | <strong><?php echo esc_html( wc_attribute_label( $attribute->get_name() ) ); ?></strong> |
| 23 | <input type="hidden" name="attribute_names[<?php echo esc_attr( $i ); ?>]" value="<?php echo esc_attr( $attribute->get_name() ); ?>" /> |
| 24 | <?php else : ?> |
| 25 | <input type="text" class="attribute_name" name="attribute_names[<?php echo esc_attr( $i ); ?>]" value="<?php echo esc_attr( $attribute->get_name() ); ?>" placeholder="<?php esc_attr_e( 'e.g. length or weight', 'woocommerce' ); ?>" /> |
| 26 | <?php endif; ?> |
| 27 | <input type="hidden" name="attribute_position[<?php echo esc_attr( $i ); ?>]" class="attribute_position" value="<?php echo esc_attr( $attribute->get_position() ); ?>" /> |
| 28 | </td> |
| 29 | <td rowspan="3"> |
| 30 | <label><?php esc_html_e( 'Value(s)', 'woocommerce' ); ?>:</label> |
| 31 | <?php |
| 32 | if ( $attribute->is_taxonomy() && $attribute->get_taxonomy_object() ) { |
| 33 | $attribute_taxonomy = $attribute->get_taxonomy_object(); |
| 34 | $attribute_types = wc_get_attribute_types(); |
| 35 | |
| 36 | if ( ! array_key_exists( $attribute_taxonomy->attribute_type, $attribute_types ) ) { |
| 37 | $attribute_taxonomy->attribute_type = 'select'; |
| 38 | } |
| 39 | |
| 40 | if ( |
| 41 | 'select' === $attribute_taxonomy->attribute_type || |
| 42 | 'wc-visual' === $attribute_taxonomy->attribute_type |
| 43 | ) { |
| 44 | $is_visual_attribute = 'wc-visual' === $attribute_taxonomy->attribute_type; |
| 45 | $attribute_orderby = ! empty( $attribute_taxonomy->attribute_orderby ) ? $attribute_taxonomy->attribute_orderby : 'name'; |
| 46 | /** |
| 47 | * Filter the length (number of terms) rendered in the list. |
| 48 | * |
| 49 | * @since 8.8.0 |
| 50 | * @param int $term_limit The maximum number of terms to display in the list. |
| 51 | */ |
| 52 | $term_limit = absint( apply_filters( 'woocommerce_admin_terms_metabox_datalimit', 50 ) ); |
| 53 | ?> |
| 54 | <select multiple="multiple" |
| 55 | data-minimum_input_length="0" |
| 56 | data-limit="<?php echo esc_attr( $term_limit ); ?>" data-return_id="id" |
| 57 | data-placeholder="<?php esc_attr_e( 'Select values', 'woocommerce' ); ?>" |
| 58 | data-orderby="<?php echo esc_attr( $attribute_orderby ); ?>" |
| 59 | class="multiselect attribute_values wc-taxonomy-term-search" |
| 60 | name="attribute_values[<?php echo esc_attr( $i ); ?>][]" |
| 61 | data-taxonomy="<?php echo esc_attr( $attribute->get_taxonomy() ); ?>" |
| 62 | data-is-visual-attribute="<?php echo esc_attr( wc_bool_to_string( $is_visual_attribute ) ); ?>"> |
| 63 | <?php |
| 64 | $selected_terms = $attribute->get_terms(); |
| 65 | $term_visuals = array(); |
| 66 | |
| 67 | if ( $selected_terms && $is_visual_attribute ) { |
| 68 | $term_visuals = VisualAttributeTermMeta::get_term_visuals( wp_list_pluck( $selected_terms, 'term_id' ) ); |
| 69 | } |
| 70 | |
| 71 | if ( $selected_terms ) { |
| 72 | foreach ( $selected_terms as $selected_term ) { |
| 73 | $option_attributes = array( |
| 74 | 'value' => $selected_term->term_id, |
| 75 | 'selected' => 'selected', |
| 76 | ); |
| 77 | |
| 78 | if ( $is_visual_attribute ) { |
| 79 | $option_attributes['data-visual'] = wp_json_encode( |
| 80 | $term_visuals[ $selected_term->term_id ] ?? VisualAttributeTermMeta::get_empty_visual() |
| 81 | ); |
| 82 | } |
| 83 | |
| 84 | $option_attribute_string = ''; |
| 85 | |
| 86 | foreach ( $option_attributes as $attribute_name => $attribute_value ) { |
| 87 | $option_attribute_string .= sprintf( |
| 88 | ' %1$s="%2$s"', |
| 89 | esc_attr( $attribute_name ), |
| 90 | esc_attr( $attribute_value ) |
| 91 | ); |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * Filter the selected attribute term name. |
| 96 | * |
| 97 | * @since 3.4.0 |
| 98 | * @param string $name Name of selected term. |
| 99 | * @param array $term The selected term object. |
| 100 | */ |
| 101 | echo '<option' . $option_attribute_string . '>' . esc_html( apply_filters( 'woocommerce_product_attribute_term_name', $selected_term->name, $selected_term ) ) . '</option>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 102 | } |
| 103 | } |
| 104 | ?> |
| 105 | </select> |
| 106 | <button class="button plus select_all_attributes"><?php esc_html_e( 'Select all', 'woocommerce' ); ?></button> |
| 107 | <button class="button minus select_no_attributes"><?php esc_html_e( 'Select none', 'woocommerce' ); ?></button> |
| 108 | <button class="button fr plus add_new_attribute" data-is-visual-attribute="<?php echo esc_attr( wc_bool_to_string( 'wc-visual' === $attribute_taxonomy->attribute_type ) ); ?>"><?php esc_html_e( 'Create value', 'woocommerce' ); ?></button> |
| 109 | <?php |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * Hook to display custom attribute terms. |
| 114 | * |
| 115 | * @since 3.4.0 |
| 116 | * @param array|null $attribute_taxonomy Attribute taxonomy object. |
| 117 | * @param int $i Attribute index. |
| 118 | * @param WC_Product_Attribute $attribute Attribute object. |
| 119 | */ |
| 120 | do_action( 'woocommerce_product_option_terms', $attribute_taxonomy, $i, $attribute ); |
| 121 | } else { |
| 122 | ?> |
| 123 | <textarea name="attribute_values[<?php echo esc_attr( $i ); ?>]" cols="5" rows="5"><?php echo esc_textarea( wc_implode_text_attributes( $attribute->get_options() ) ); ?></textarea> |
| 124 | <?php |
| 125 | } |
| 126 | ?> |
| 127 | </td> |
| 128 | </tr> |
| 129 | <tr> |
| 130 | <td> |
| 131 | <label><input type="checkbox" class="woocommerce_attribute_visible_on_product_page checkbox" <?php checked( $attribute->get_visible(), true ); ?> name="attribute_visibility[<?php echo esc_attr( $i ); ?>]" value="1" /> <?php esc_html_e( 'Visible on the product page', 'woocommerce' ); ?></label> |
| 132 | </td> |
| 133 | </tr> |
| 134 | <tr> |
| 135 | <td> |
| 136 | <div class="enable_variation show_if_variable"> |
| 137 | <label><input type="checkbox" class="woocommerce_attribute_used_for_variations checkbox" <?php checked( $attribute->get_variation(), true ); ?> name="attribute_variation[<?php echo esc_attr( $i ); ?>]" value="1" /> <?php esc_html_e( 'Used for variations', 'woocommerce' ); ?></label> |
| 138 | </div> |
| 139 | </td> |
| 140 | </tr> |
| 141 | <?php |
| 142 | /** |
| 143 | * Hook to display custom attribute terms. |
| 144 | * |
| 145 | * @since 3.4.0 |
| 146 | * @param WC_Product_Attribute $attribute Attribute object. |
| 147 | * @param int $i Attribute index. |
| 148 | */ |
| 149 | do_action( 'woocommerce_after_product_attribute_settings', $attribute, $i ); |
| 150 | ?> |
| 151 | </tbody> |
| 152 | </table> |
| 153 |