html-product-data-variations.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <?php
  2. /**
  3. * Product data variations
  4. *
  5. * @package WooCommerce\Admin\Metaboxes\Views
  6. */
  7. if ( ! defined( 'ABSPATH' ) ) {
  8. exit;
  9. }
  10. ?>
  11. <div id="variable_product_options" class="panel wc-metaboxes-wrapper hidden">
  12. <div id="variable_product_options_inner">
  13. <?php if ( ! count( $variation_attributes ) ) : ?>
  14. <div id="message" class="inline notice woocommerce-message">
  15. <p><?php echo wp_kses_post( __( 'Before you can add a variation you need to add some variation attributes on the <strong>Attributes</strong> tab.', 'woocommerce' ) ); ?></p>
  16. <p><a class="button-primary" href="<?php echo esc_url( apply_filters( 'woocommerce_docs_url', 'https://docs.woocommerce.com/document/variable-product/', 'product-variations' ) ); ?>" target="_blank"><?php esc_html_e( 'Learn more', 'woocommerce' ); ?></a></p>
  17. </div>
  18. <?php else : ?>
  19. <div class="toolbar toolbar-variations-defaults">
  20. <div class="variations-defaults">
  21. <strong><?php esc_html_e( 'Default Form Values', 'woocommerce' ); ?>: <?php echo wc_help_tip( __( 'These are the attributes that will be pre-selected on the frontend.', 'woocommerce' ) ); ?></strong>
  22. <?php
  23. foreach ( $variation_attributes as $attribute ) {
  24. $selected_value = isset( $default_attributes[ sanitize_title( $attribute->get_name() ) ] ) ? $default_attributes[ sanitize_title( $attribute->get_name() ) ] : '';
  25. ?>
  26. <select name="default_attribute_<?php echo esc_attr( sanitize_title( $attribute->get_name() ) ); ?>" data-current="<?php echo esc_attr( $selected_value ); ?>">
  27. <?php /* translators: WooCommerce attribute label */ ?>
  28. <option value=""><?php echo esc_html( sprintf( __( 'No default %s&hellip;', 'woocommerce' ), wc_attribute_label( $attribute->get_name() ) ) ); ?></option>
  29. <?php if ( $attribute->is_taxonomy() ) : ?>
  30. <?php foreach ( $attribute->get_terms() as $option ) : ?>
  31. <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>
  32. <?php endforeach; ?>
  33. <?php else : ?>
  34. <?php foreach ( $attribute->get_options() as $option ) : ?>
  35. <option <?php selected( $selected_value, $option ); ?> value="<?php echo esc_attr( $option ); ?>"><?php echo esc_html( apply_filters( 'woocommerce_variation_option_name', $option ) ); ?></option>
  36. <?php endforeach; ?>
  37. <?php endif; ?>
  38. </select>
  39. <?php
  40. }
  41. ?>
  42. </div>
  43. <div class="clear"></div>
  44. </div>
  45. <?php do_action( 'woocommerce_variable_product_before_variations' ); ?>
  46. <div class="toolbar toolbar-top">
  47. <select id="field_to_edit" class="variation_actions">
  48. <option data-global="true" value="add_variation"><?php esc_html_e( 'Add variation', 'woocommerce' ); ?></option>
  49. <option data-global="true" value="link_all_variations"><?php esc_html_e( 'Create variations from all attributes', 'woocommerce' ); ?></option>
  50. <option value="delete_all"><?php esc_html_e( 'Delete all variations', 'woocommerce' ); ?></option>
  51. <optgroup label="<?php esc_attr_e( 'Status', 'woocommerce' ); ?>">
  52. <option value="toggle_enabled"><?php esc_html_e( 'Toggle &quot;Enabled&quot;', 'woocommerce' ); ?></option>
  53. <option value="toggle_downloadable"><?php esc_html_e( 'Toggle &quot;Downloadable&quot;', 'woocommerce' ); ?></option>
  54. <option value="toggle_virtual"><?php esc_html_e( 'Toggle &quot;Virtual&quot;', 'woocommerce' ); ?></option>
  55. </optgroup>
  56. <optgroup label="<?php esc_attr_e( 'Pricing', 'woocommerce' ); ?>">
  57. <option value="variable_regular_price"><?php esc_html_e( 'Set regular prices', 'woocommerce' ); ?></option>
  58. <option value="variable_regular_price_increase"><?php esc_html_e( 'Increase regular prices (fixed amount or percentage)', 'woocommerce' ); ?></option>
  59. <option value="variable_regular_price_decrease"><?php esc_html_e( 'Decrease regular prices (fixed amount or percentage)', 'woocommerce' ); ?></option>
  60. <option value="variable_sale_price"><?php esc_html_e( 'Set sale prices', 'woocommerce' ); ?></option>
  61. <option value="variable_sale_price_increase"><?php esc_html_e( 'Increase sale prices (fixed amount or percentage)', 'woocommerce' ); ?></option>
  62. <option value="variable_sale_price_decrease"><?php esc_html_e( 'Decrease sale prices (fixed amount or percentage)', 'woocommerce' ); ?></option>
  63. <option value="variable_sale_schedule"><?php esc_html_e( 'Set scheduled sale dates', 'woocommerce' ); ?></option>
  64. </optgroup>
  65. <optgroup label="<?php esc_attr_e( 'Inventory', 'woocommerce' ); ?>">
  66. <option value="toggle_manage_stock"><?php esc_html_e( 'Toggle &quot;Manage stock&quot;', 'woocommerce' ); ?></option>
  67. <option value="variable_stock"><?php esc_html_e( 'Stock', 'woocommerce' ); ?></option>
  68. <option value="variable_stock_status_instock"><?php esc_html_e( 'Set Status - In stock', 'woocommerce' ); ?></option>
  69. <option value="variable_stock_status_outofstock"><?php esc_html_e( 'Set Status - Out of stock', 'woocommerce' ); ?></option>
  70. <option value="variable_stock_status_onbackorder"><?php esc_html_e( 'Set Status - On backorder', 'woocommerce' ); ?></option>
  71. </optgroup>
  72. <optgroup label="<?php esc_attr_e( 'Shipping', 'woocommerce' ); ?>">
  73. <option value="variable_length"><?php esc_html_e( 'Length', 'woocommerce' ); ?></option>
  74. <option value="variable_width"><?php esc_html_e( 'Width', 'woocommerce' ); ?></option>
  75. <option value="variable_height"><?php esc_html_e( 'Height', 'woocommerce' ); ?></option>
  76. <option value="variable_weight"><?php esc_html_e( 'Weight', 'woocommerce' ); ?></option>
  77. </optgroup>
  78. <optgroup label="<?php esc_attr_e( 'Downloadable products', 'woocommerce' ); ?>">
  79. <option value="variable_download_limit"><?php esc_html_e( 'Download limit', 'woocommerce' ); ?></option>
  80. <option value="variable_download_expiry"><?php esc_html_e( 'Download expiry', 'woocommerce' ); ?></option>
  81. </optgroup>
  82. <?php do_action( 'woocommerce_variable_product_bulk_edit_actions' ); ?>
  83. </select>
  84. <a class="button bulk_edit do_variation_action"><?php esc_html_e( 'Go', 'woocommerce' ); ?></a>
  85. <div class="variations-pagenav">
  86. <?php /* translators: variations count */ ?>
  87. <span class="displaying-num"><?php echo esc_html( sprintf( _n( '%s item', '%s items', $variations_count, 'woocommerce' ), $variations_count ) ); ?></span>
  88. <span class="expand-close">
  89. (<a href="#" class="expand_all"><?php esc_html_e( 'Expand', 'woocommerce' ); ?></a> / <a href="#" class="close_all"><?php esc_html_e( 'Close', 'woocommerce' ); ?></a>)
  90. </span>
  91. <span class="pagination-links">
  92. <a class="first-page disabled" title="<?php esc_attr_e( 'Go to the first page', 'woocommerce' ); ?>" href="#">&laquo;</a>
  93. <a class="prev-page disabled" title="<?php esc_attr_e( 'Go to the previous page', 'woocommerce' ); ?>" href="#">&lsaquo;</a>
  94. <span class="paging-select">
  95. <label for="current-page-selector-1" class="screen-reader-text"><?php esc_html_e( 'Select Page', 'woocommerce' ); ?></label>
  96. <select class="page-selector" id="current-page-selector-1" title="<?php esc_attr_e( 'Current page', 'woocommerce' ); ?>">
  97. <?php for ( $i = 1; $i <= $variations_total_pages; $i++ ) : ?>
  98. <option value="<?php echo $i; // WPCS: XSS ok. ?>"><?php echo $i; // WPCS: XSS ok. ?></option>
  99. <?php endfor; ?>
  100. </select>
  101. <?php echo esc_html_x( 'of', 'number of pages', 'woocommerce' ); ?> <span class="total-pages"><?php echo esc_html( $variations_total_pages ); ?></span>
  102. </span>
  103. <a class="next-page" title="<?php esc_attr_e( 'Go to the next page', 'woocommerce' ); ?>" href="#">&rsaquo;</a>
  104. <a class="last-page" title="<?php esc_attr_e( 'Go to the last page', 'woocommerce' ); ?>" href="#">&raquo;</a>
  105. </span>
  106. </div>
  107. <div class="clear"></div>
  108. </div>
  109. <?php
  110. // esc_attr does not double encode - htmlspecialchars does.
  111. $attributes_data = htmlspecialchars( wp_json_encode( wc_list_pluck( $variation_attributes, 'get_data' ) ) );
  112. ?>
  113. <div class="woocommerce_variations wc-metaboxes" data-attributes="<?php echo $attributes_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">
  114. </div>
  115. <div class="toolbar">
  116. <button type="button" class="button-primary save-variation-changes" disabled="disabled"><?php esc_html_e( 'Save changes', 'woocommerce' ); ?></button>
  117. <button type="button" class="button cancel-variation-changes" disabled="disabled"><?php esc_html_e( 'Cancel', 'woocommerce' ); ?></button>
  118. <div class="variations-pagenav">
  119. <?php /* translators: variations count*/ ?>
  120. <span class="displaying-num"><?php echo esc_html( sprintf( _n( '%s item', '%s items', $variations_count, 'woocommerce' ), $variations_count ) ); ?></span>
  121. <span class="expand-close">
  122. (<a href="#" class="expand_all"><?php esc_html_e( 'Expand', 'woocommerce' ); ?></a> / <a href="#" class="close_all"><?php esc_html_e( 'Close', 'woocommerce' ); ?></a>)
  123. </span>
  124. <span class="pagination-links">
  125. <a class="first-page disabled" title="<?php esc_attr_e( 'Go to the first page', 'woocommerce' ); ?>" href="#">&laquo;</a>
  126. <a class="prev-page disabled" title="<?php esc_attr_e( 'Go to the previous page', 'woocommerce' ); ?>" href="#">&lsaquo;</a>
  127. <span class="paging-select">
  128. <label for="current-page-selector-1" class="screen-reader-text"><?php esc_html_e( 'Select Page', 'woocommerce' ); ?></label>
  129. <select class="page-selector" id="current-page-selector-1" title="<?php esc_attr_e( 'Current page', 'woocommerce' ); ?>">
  130. <?php for ( $i = 1; $i <= $variations_total_pages; $i++ ) : ?>
  131. <option value="<?php echo $i; // WPCS: XSS ok. ?>"><?php echo $i; // WPCS: XSS ok. ?></option>
  132. <?php endfor; ?>
  133. </select>
  134. <?php echo esc_html_x( 'of', 'number of pages', 'woocommerce' ); ?> <span class="total-pages"><?php echo esc_html( $variations_total_pages ); ?></span>
  135. </span>
  136. <a class="next-page" title="<?php esc_attr_e( 'Go to the next page', 'woocommerce' ); ?>" href="#">&rsaquo;</a>
  137. <a class="last-page" title="<?php esc_attr_e( 'Go to the last page', 'woocommerce' ); ?>" href="#">&raquo;</a>
  138. </span>
  139. </div>
  140. <div class="clear"></div>
  141. </div>
  142. <?php endif; ?>
  143. </div>
  144. </div>