html-order-download-permission.php
6 years ago
html-order-fee.php
3 months ago
html-order-item-meta.php
4 years ago
html-order-item.php
9 months ago
html-order-items.php
1 month ago
html-order-notes.php
1 month ago
html-order-refund.php
3 months ago
html-order-shipping.php
3 months ago
html-product-attribute-inner.php
1 month ago
html-product-attribute.php
3 years ago
html-product-data-advanced.php
5 months ago
html-product-data-attributes.php
1 month ago
html-product-data-general.php
2 months ago
html-product-data-inventory.php
4 months ago
html-product-data-linked-products.php
3 months ago
html-product-data-panel.php
1 year ago
html-product-data-shipping.php
3 years ago
html-product-data-variations.php
1 month ago
html-product-download.php
4 months ago
html-product-variation-download.php
4 months ago
html-variation-admin.php
1 month ago
html-product-data-variations.php
245 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Product data variations |
| 4 | * |
| 5 | * @package WooCommerce\Admin\Metaboxes\Views |
| 6 | */ |
| 7 | |
| 8 | use Automattic\WooCommerce\Admin\Features\Features; |
| 9 | use Automattic\WooCommerce\Admin\Features\ProductVariationsClassicRedesign; |
| 10 | use Automattic\WooCommerce\Internal\CostOfGoodsSold\CostOfGoodsSoldController; |
| 11 | |
| 12 | if ( ! defined( 'ABSPATH' ) ) { |
| 13 | exit; |
| 14 | } |
| 15 | |
| 16 | if ( Features::exists( ProductVariationsClassicRedesign::FEATURE_ID ) ) { |
| 17 | ?> |
| 18 | <div id="variable_product_options" class="panel wc-metaboxes-wrapper hidden"> |
| 19 | <div id="variable_product_options_inner"> |
| 20 | <div id="<?php echo esc_attr( ProductVariationsClassicRedesign::ROOT_ID ); ?>"></div> |
| 21 | </div> |
| 22 | </div> |
| 23 | <?php |
| 24 | return; |
| 25 | } |
| 26 | |
| 27 | $add_attributes_img_url = WC_ADMIN_IMAGES_FOLDER_URL . '/icons/info.svg'; |
| 28 | $background_img_url = WC_ADMIN_IMAGES_FOLDER_URL . '/product_data/no-variation-background-image.svg'; |
| 29 | $arrow_img_url = WC_ADMIN_IMAGES_FOLDER_URL . '/product_data/no-variation-arrow.svg'; |
| 30 | ?> |
| 31 | <div id="variable_product_options" class="panel wc-metaboxes-wrapper hidden"> |
| 32 | <div id="variable_product_options_inner"> |
| 33 | <?php if ( ! isset( $variation_attributes ) || ! is_array( $variation_attributes ) || count( $variation_attributes ) === 0 ) : ?> |
| 34 | |
| 35 | <div class="add-attributes-container"> |
| 36 | <div class="add-attributes-message"> |
| 37 | <img src="<?php echo esc_url( $add_attributes_img_url ); ?>" /> |
| 38 | <p> |
| 39 | <?php |
| 40 | echo wp_kses_post( |
| 41 | sprintf( |
| 42 | /* translators: %1$s: url for attributes tab, %2$s: url for variable product documentation */ |
| 43 | __( 'Add some attributes in the <a class="variations-add-attributes-link" href="%1$s">Attributes</a> tab to generate variations. Make sure to check the <b>Used for variations</b> box. <a class="variations-learn-more-link" href="%2$s" target="_blank" rel="noreferrer">Learn more</a>', 'woocommerce' ), |
| 44 | esc_url( '#product_attributes' ), |
| 45 | esc_url( 'https://woocommerce.com/document/variable-product/' ) |
| 46 | ) |
| 47 | ); |
| 48 | ?> |
| 49 | </p> |
| 50 | </div> |
| 51 | </div> |
| 52 | |
| 53 | <?php else : ?> |
| 54 | |
| 55 | <div class="toolbar toolbar-variations-defaults"> |
| 56 | <div class="variations-defaults"> |
| 57 | <strong><?php esc_html_e( 'Default Form Values', 'woocommerce' ); ?>: <?php echo wc_help_tip( __( 'Choose a default form value if you want a certain variation already selected when a user visits the product page.', 'woocommerce' ) ); ?></strong> |
| 58 | <?php |
| 59 | foreach ( $variation_attributes as $attribute ) { |
| 60 | $selected_value = isset( $default_attributes[ sanitize_title( $attribute->get_name() ) ] ) ? $default_attributes[ sanitize_title( $attribute->get_name() ) ] : ''; |
| 61 | ?> |
| 62 | <select name="default_attribute_<?php echo esc_attr( sanitize_title( $attribute->get_name() ) ); ?>" data-current="<?php echo esc_attr( $selected_value ); ?>"> |
| 63 | <?php /* translators: WooCommerce attribute label */ ?> |
| 64 | <option value=""><?php echo esc_html( sprintf( __( 'No default %s…', 'woocommerce' ), wc_attribute_label( $attribute->get_name() ) ) ); ?></option> |
| 65 | <?php if ( $attribute->is_taxonomy() ) : ?> |
| 66 | <?php foreach ( $attribute->get_terms() as $option ) : ?> |
| 67 | <?php /* phpcs:disable WooCommerce.Commenting.CommentHooks.MissingHookComment */ ?> |
| 68 | <option <?php selected( $selected_value, $option->slug ); ?> value="<?php echo esc_attr( $option->slug ); ?>"><?php echo esc_html( apply_filters( 'woocommerce_variation_option_name', $option->name, $option, $attribute->get_name(), $product_object ) ); ?></option> |
| 69 | <?php /* phpcs:enable */ ?> |
| 70 | <?php endforeach; ?> |
| 71 | <?php else : ?> |
| 72 | <?php foreach ( $attribute->get_options() as $option ) : ?> |
| 73 | <?php /* phpcs:disable WooCommerce.Commenting.CommentHooks.MissingHookComment */ ?> |
| 74 | <option <?php selected( $selected_value, $option ); ?> value="<?php echo esc_attr( $option ); ?>"><?php echo esc_html( apply_filters( 'woocommerce_variation_option_name', $option, null, $attribute->get_name(), $product_object ) ); ?></option> |
| 75 | <?php /* phpcs:enable */ ?> |
| 76 | <?php endforeach; ?> |
| 77 | <?php endif; ?> |
| 78 | </select> |
| 79 | <?php |
| 80 | } |
| 81 | ?> |
| 82 | </div> |
| 83 | <div class="clear"></div> |
| 84 | </div> |
| 85 | |
| 86 | <?php /* phpcs:disable WooCommerce.Commenting.CommentHooks.MissingHookComment */ ?> |
| 87 | <?php do_action( 'woocommerce_variable_product_before_variations' ); ?> |
| 88 | <?php /* phpcs:enable */ ?> |
| 89 | |
| 90 | <div class="toolbar toolbar-top"> |
| 91 | <button type="button" class="button generate_variations"><?php esc_html_e( 'Generate variations', 'woocommerce' ); ?></button> |
| 92 | <button type="button" class="button add_variation_manually"><?php esc_html_e( 'Add manually', 'woocommerce' ); ?></button> |
| 93 | <select id="field_to_edit" class="select variation_actions hidden"> |
| 94 | <option value="bulk_actions" disabled>Bulk actions</option> |
| 95 | <option value="delete_all"><?php esc_html_e( 'Delete all variations', 'woocommerce' ); ?></option> |
| 96 | <optgroup label="<?php esc_attr_e( 'Status', 'woocommerce' ); ?>"> |
| 97 | <option value="toggle_enabled"><?php esc_html_e( 'Toggle "Enabled"', 'woocommerce' ); ?></option> |
| 98 | <option value="toggle_downloadable"><?php esc_html_e( 'Toggle "Downloadable"', 'woocommerce' ); ?></option> |
| 99 | <option value="toggle_virtual"><?php esc_html_e( 'Toggle "Virtual"', 'woocommerce' ); ?></option> |
| 100 | </optgroup> |
| 101 | <optgroup label="<?php esc_attr_e( 'Pricing', 'woocommerce' ); ?>"> |
| 102 | <option value="variable_regular_price"><?php esc_html_e( 'Set regular prices', 'woocommerce' ); ?></option> |
| 103 | <option value="variable_regular_price_increase"><?php esc_html_e( 'Increase regular prices (fixed amount or percentage)', 'woocommerce' ); ?></option> |
| 104 | <option value="variable_regular_price_decrease"><?php esc_html_e( 'Decrease regular prices (fixed amount or percentage)', 'woocommerce' ); ?></option> |
| 105 | <option value="variable_sale_price"><?php esc_html_e( 'Set sale prices', 'woocommerce' ); ?></option> |
| 106 | <option value="variable_sale_price_increase"><?php esc_html_e( 'Increase sale prices (fixed amount or percentage)', 'woocommerce' ); ?></option> |
| 107 | <option value="variable_sale_price_decrease"><?php esc_html_e( 'Decrease sale prices (fixed amount or percentage)', 'woocommerce' ); ?></option> |
| 108 | <option value="variable_sale_schedule"><?php esc_html_e( 'Set scheduled sale dates', 'woocommerce' ); ?></option> |
| 109 | </optgroup> |
| 110 | <?php if ( wc_get_container()->get( CostOfGoodsSoldController::class )->feature_is_enabled() ) : ?> |
| 111 | <optgroup label="<?php esc_attr_e( 'Cost of goods', 'woocommerce' ); ?>"> |
| 112 | <option value="variable_unset_cogs_value"><?php esc_html_e( 'Remove custom costs', 'woocommerce' ); ?></option> |
| 113 | </optgroup> |
| 114 | <?php endif; ?> |
| 115 | <optgroup label="<?php esc_attr_e( 'Inventory', 'woocommerce' ); ?>"> |
| 116 | <option value="toggle_manage_stock"><?php esc_html_e( 'Toggle "Manage stock"', 'woocommerce' ); ?></option> |
| 117 | <option value="variable_stock"><?php esc_html_e( 'Stock', 'woocommerce' ); ?></option> |
| 118 | <option value="variable_stock_status_instock"><?php esc_html_e( 'Set Status - In stock', 'woocommerce' ); ?></option> |
| 119 | <option value="variable_stock_status_outofstock"><?php esc_html_e( 'Set Status - Out of stock', 'woocommerce' ); ?></option> |
| 120 | <option value="variable_stock_status_onbackorder"><?php esc_html_e( 'Set Status - On backorder', 'woocommerce' ); ?></option> |
| 121 | <option value="variable_low_stock_amount"><?php esc_html_e( 'Low stock threshold', 'woocommerce' ); ?></option> |
| 122 | </optgroup> |
| 123 | <optgroup label="<?php esc_attr_e( 'Shipping', 'woocommerce' ); ?>"> |
| 124 | <option value="variable_length"><?php esc_html_e( 'Length', 'woocommerce' ); ?></option> |
| 125 | <option value="variable_width"><?php esc_html_e( 'Width', 'woocommerce' ); ?></option> |
| 126 | <option value="variable_height"><?php esc_html_e( 'Height', 'woocommerce' ); ?></option> |
| 127 | <option value="variable_weight"><?php esc_html_e( 'Weight', 'woocommerce' ); ?></option> |
| 128 | </optgroup> |
| 129 | <optgroup label="<?php esc_attr_e( 'Downloadable products', 'woocommerce' ); ?>"> |
| 130 | <option value="variable_download_limit"><?php esc_html_e( 'Download limit', 'woocommerce' ); ?></option> |
| 131 | <option value="variable_download_expiry"><?php esc_html_e( 'Download expiry', 'woocommerce' ); ?></option> |
| 132 | </optgroup> |
| 133 | <?php /* phpcs:disable WooCommerce.Commenting.CommentHooks.MissingHookComment */ ?> |
| 134 | <?php do_action( 'woocommerce_variable_product_bulk_edit_actions' ); ?> |
| 135 | <?php /* phpcs:enable */ ?> |
| 136 | </select> |
| 137 | |
| 138 | <div class="variations-pagenav"> |
| 139 | <?php /* translators: variations count */ ?> |
| 140 | <span class="displaying-num"><?php echo esc_html( sprintf( _n( '%s item', '%s items', $variations_count, 'woocommerce' ), $variations_count ) ); ?></span> |
| 141 | <span class="expand-close"> |
| 142 | (<a href="#" class="expand_all"><?php esc_html_e( 'Expand', 'woocommerce' ); ?></a> / <a href="#" class="close_all"><?php esc_html_e( 'Close', 'woocommerce' ); ?></a>) |
| 143 | </span> |
| 144 | <span class="pagination-links"> |
| 145 | <a class="first-page disabled" title="<?php esc_attr_e( 'Go to the first page', 'woocommerce' ); ?>" href="#">«</a> |
| 146 | <a class="prev-page disabled" title="<?php esc_attr_e( 'Go to the previous page', 'woocommerce' ); ?>" href="#">‹</a> |
| 147 | <span class="paging-select"> |
| 148 | <label for="current-page-selector-1" class="screen-reader-text"><?php esc_html_e( 'Select Page', 'woocommerce' ); ?></label> |
| 149 | <select class="page-selector" id="current-page-selector-1" title="<?php esc_attr_e( 'Current page', 'woocommerce' ); ?>"> |
| 150 | <?php for ( $i = 1; $i <= $variations_total_pages; $i++ ) : ?> |
| 151 | <?php /* phpcs:disable WooCommerce.Commenting.CommentHooks.MissingHookComment */ ?> |
| 152 | <option value="<?php echo $i; // WPCS: XSS ok. ?>"><?php echo $i; // WPCS: XSS ok. ?></option> |
| 153 | <?php /* phpcs:enable */ ?> |
| 154 | <?php endfor; ?> |
| 155 | </select> |
| 156 | <?php echo esc_html_x( 'of', 'number of pages', 'woocommerce' ); ?> <span class="total-pages"><?php echo esc_html( $variations_total_pages ); ?></span> |
| 157 | </span> |
| 158 | <a class="next-page" title="<?php esc_attr_e( 'Go to the next page', 'woocommerce' ); ?>" href="#">›</a> |
| 159 | <a class="last-page" title="<?php esc_attr_e( 'Go to the last page', 'woocommerce' ); ?>" href="#">»</a> |
| 160 | </span> |
| 161 | </div> |
| 162 | <div class="clear"></div> |
| 163 | </div> |
| 164 | |
| 165 | <div class="add-variation-container"> |
| 166 | <div class="arrow-image-wrapper"> |
| 167 | <img src="<?php echo esc_url( $arrow_img_url ); ?>" /> |
| 168 | </div> |
| 169 | <img src="<?php echo esc_url( $background_img_url ); ?>" /> |
| 170 | <p> |
| 171 | <?php |
| 172 | esc_html_e( |
| 173 | 'No variations yet. Generate them from all added attributes or add a new variation manually.', |
| 174 | 'woocommerce' |
| 175 | ); |
| 176 | ?> |
| 177 | </p> |
| 178 | </div> |
| 179 | |
| 180 | <?php /* phpcs:disable WooCommerce.Commenting.CommentHooks.MissingHookComment */ ?> |
| 181 | <div class="woocommerce_variations wc-metaboxes" data-attributes="<?php echo wc_esc_json( wp_json_encode( wc_list_pluck( $variation_attributes, 'get_data' ) ) ); // WPCS: XSS ok. ?>" data-total="<?php echo esc_attr( $variations_count ); ?>" data-total_pages="<?php echo esc_attr( $variations_total_pages ); ?>" data-page="1" data-edited="false"></div> |
| 182 | <?php /* phpcs:enable */ ?> |
| 183 | |
| 184 | <div class="toolbar"> |
| 185 | <button type="button" class="button-primary save-variation-changes" disabled="disabled"><?php esc_html_e( 'Save changes', 'woocommerce' ); ?></button> |
| 186 | <button type="button" class="button cancel-variation-changes" disabled="disabled"><?php esc_html_e( 'Cancel', 'woocommerce' ); ?></button> |
| 187 | |
| 188 | <div class="variations-pagenav"> |
| 189 | <?php /* translators: variations count*/ ?> |
| 190 | <span class="displaying-num"><?php echo esc_html( sprintf( _n( '%s item', '%s items', $variations_count, 'woocommerce' ), $variations_count ) ); ?></span> |
| 191 | <span class="expand-close"> |
| 192 | (<a href="#" class="expand_all"><?php esc_html_e( 'Expand', 'woocommerce' ); ?></a> / <a href="#" class="close_all"><?php esc_html_e( 'Close', 'woocommerce' ); ?></a>) |
| 193 | </span> |
| 194 | <span class="pagination-links"> |
| 195 | <a class="first-page disabled" title="<?php esc_attr_e( 'Go to the first page', 'woocommerce' ); ?>" href="#">«</a> |
| 196 | <a class="prev-page disabled" title="<?php esc_attr_e( 'Go to the previous page', 'woocommerce' ); ?>" href="#">‹</a> |
| 197 | <span class="paging-select"> |
| 198 | <label for="current-page-selector-1" class="screen-reader-text"><?php esc_html_e( 'Select Page', 'woocommerce' ); ?></label> |
| 199 | <select class="page-selector" id="current-page-selector-1" title="<?php esc_attr_e( 'Current page', 'woocommerce' ); ?>"> |
| 200 | <?php for ( $i = 1; $i <= $variations_total_pages; $i++ ) : ?> |
| 201 | <?php /* phpcs:disable WooCommerce.Commenting.CommentHooks.MissingHookComment */ ?> |
| 202 | <option value="<?php echo $i; // WPCS: XSS ok. ?>"><?php echo $i; // WPCS: XSS ok. ?></option> |
| 203 | <?php /* phpcs:enable */ ?> |
| 204 | <?php endfor; ?> |
| 205 | </select> |
| 206 | <?php echo esc_html_x( 'of', 'number of pages', 'woocommerce' ); ?> <span class="total-pages"><?php echo esc_html( $variations_total_pages ); ?></span> |
| 207 | </span> |
| 208 | <a class="next-page" title="<?php esc_attr_e( 'Go to the next page', 'woocommerce' ); ?>" href="#">›</a> |
| 209 | <a class="last-page" title="<?php esc_attr_e( 'Go to the last page', 'woocommerce' ); ?>" href="#">»</a> |
| 210 | </span> |
| 211 | </div> |
| 212 | <div class="clear"></div> |
| 213 | </div> |
| 214 | |
| 215 | <?php endif; ?> |
| 216 | </div> |
| 217 | </div> |
| 218 | <script type="text/template" id="tmpl-wc-modal-set-price-variations"> |
| 219 | <div class="wc-backbone-modal wc-backbone-modal-set-price-variations"> |
| 220 | <div class="wc-backbone-modal-content"> |
| 221 | <section class="wc-backbone-modal-main" role="main"> |
| 222 | <header class="wc-backbone-modal-header"> |
| 223 | <h1><?php esc_html_e( 'Set variation prices', 'woocommerce' ); ?></h1> |
| 224 | <button class="modal-close modal-close-link dashicons dashicons-no-alt"> |
| 225 | <span class="screen-reader-text"><?php esc_html_e( 'Close modal panel', 'woocommerce' ); ?></span> |
| 226 | </button> |
| 227 | </header> |
| 228 | <article> |
| 229 | <div> |
| 230 | <span><?php esc_html_e( 'Add price to all variations that don\'t have a price', 'woocommerce' ); ?> (<?php echo esc_attr( get_woocommerce_currency_symbol() ); ?> <?php echo esc_textarea( get_woocommerce_currency() ); ?>)</span> |
| 231 | <input type="text" class="components-text-control__input wc_input_variations_price"/> |
| 232 | </div> |
| 233 | </article> |
| 234 | <footer> |
| 235 | <div class="wc-backbone-modal-buttons"> |
| 236 | <button class="modal-close button components-button is-secondary"><?php esc_html_e( 'Cancel', 'woocommerce' ); ?></button> |
| 237 | <button class="modal-close button components-button add_variations_price_button button-primary" disabled><?php esc_html_e( 'Add prices', 'woocommerce' ); ?></button> |
| 238 | </div> |
| 239 | </footer> |
| 240 | </section> |
| 241 | </div> |
| 242 | </div> |
| 243 | <div class="wc-backbone-modal-backdrop modal-close"></div> |
| 244 | </script> |
| 245 |