PageRenderTime 28ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/woocommerce/includes/admin/post-types/meta-boxes/views/html-variation-admin.php

https://gitlab.com/haque.mdmanzurul/barongbarong
PHP | 221 lines | 199 code | 18 blank | 4 comment | 29 complexity | 450b6861929e4054de28308081baf38d MD5 | raw file
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
  3. ?>
  4. <div class="woocommerce_variation wc-metabox closed">
  5. <h3>
  6. <button type="button" class="remove_variation button" rel="<?php echo esc_attr( $variation_id ); ?>"><?php _e( 'Remove', 'woocommerce' ); ?></button>
  7. <div class="handlediv" title="<?php _e( 'Click to toggle', 'woocommerce' ); ?>"></div>
  8. <strong>#<?php echo esc_html( $variation_id ); ?> &mdash; </strong>
  9. <?php
  10. foreach ( $parent_data['attributes'] as $attribute ) {
  11. // Only deal with attributes that are variations
  12. if ( ! $attribute['is_variation'] ) {
  13. continue;
  14. }
  15. // Get current value for variation (if set)
  16. $variation_selected_value = isset( $variation_data[ 'attribute_' . sanitize_title( $attribute['name'] ) ][0] ) ? $variation_data[ 'attribute_' . sanitize_title( $attribute['name'] ) ][0] : '';
  17. // Name will be something like attribute_pa_color
  18. echo '<select name="attribute_' . sanitize_title( $attribute['name'] ) . '[' . $loop . ']"><option value="">' . __( 'Any', 'woocommerce' ) . ' ' . esc_html( wc_attribute_label( $attribute['name'] ) ) . '&hellip;</option>';
  19. // Get terms for attribute taxonomy or value if its a custom attribute
  20. if ( $attribute['is_taxonomy'] ) {
  21. $post_terms = wp_get_post_terms( $parent_data['id'], $attribute['name'] );
  22. foreach ( $post_terms as $term ) {
  23. echo '<option ' . selected( $variation_selected_value, $term->slug, false ) . ' value="' . esc_attr( $term->slug ) . '">' . apply_filters( 'woocommerce_variation_option_name', esc_html( $term->name ) ) . '</option>';
  24. }
  25. } else {
  26. $options = array_map( 'trim', explode( WC_DELIMITER, $attribute['value'] ) );
  27. foreach ( $options as $option ) {
  28. echo '<option ' . selected( sanitize_title( $variation_selected_value ), sanitize_title( $option ), false ) . ' value="' . esc_attr( sanitize_title( $option ) ) . '">' . esc_html( apply_filters( 'woocommerce_variation_option_name', $option ) ) . '</option>';
  29. }
  30. }
  31. echo '</select>';
  32. }
  33. ?>
  34. <input type="hidden" name="variable_post_id[<?php echo $loop; ?>]" value="<?php echo esc_attr( $variation_id ); ?>" />
  35. <input type="hidden" class="variation_menu_order" name="variation_menu_order[<?php echo $loop; ?>]" value="<?php echo $loop; ?>" />
  36. </h3>
  37. <table cellpadding="0" cellspacing="0" class="woocommerce_variable_attributes wc-metabox-content">
  38. <tbody>
  39. <tr>
  40. <td class="sku" colspan="2">
  41. <?php if ( wc_product_sku_enabled() ) : ?>
  42. <label><?php _e( 'SKU', 'woocommerce' ); ?>: <a class="tips" data-tip="<?php _e( 'Enter a SKU for this variation or leave blank to use the parent product SKU.', 'woocommerce' ); ?>" href="#">[?]</a></label>
  43. <input type="text" size="5" name="variable_sku[<?php echo $loop; ?>]" value="<?php if ( isset( $_sku ) ) echo esc_attr( $_sku ); ?>" placeholder="<?php echo esc_attr( $parent_data['sku'] ); ?>" />
  44. <?php else : ?>
  45. <input type="hidden" name="variable_sku[<?php echo $loop; ?>]" value="<?php if ( isset( $_sku ) ) echo esc_attr( $_sku ); ?>" />
  46. <?php endif; ?>
  47. </td>
  48. <td class="data" rowspan="2">
  49. <table cellspacing="0" cellpadding="0" class="data_table">
  50. <?php if ( get_option( 'woocommerce_manage_stock' ) == 'yes' ) : ?>
  51. <tr>
  52. <td>
  53. <label><?php _e( 'Stock Qty:', 'woocommerce' ); ?> <a class="tips" data-tip="<?php _e( 'Enter a quantity to enable stock management at variation level, or leave blank to use the parent product\'s options.', 'woocommerce' ); ?>" href="#">[?]</a></label>
  54. <input type="number" size="5" name="variable_stock[<?php echo $loop; ?>]" value="<?php if ( isset( $_stock ) ) echo esc_attr( $_stock ); ?>" step="any" />
  55. </td>
  56. <td>&nbsp;</td>
  57. </tr>
  58. <?php endif; ?>
  59. <tr class="variable_pricing">
  60. <td>
  61. <label><?php echo __( 'Regular Price:', 'woocommerce' ) . ' (' . get_woocommerce_currency_symbol() . ')'; ?></label>
  62. <input type="text" size="5" name="variable_regular_price[<?php echo $loop; ?>]" value="<?php if ( isset( $_regular_price ) ) echo esc_attr( $_regular_price ); ?>" class="wc_input_price" placeholder="<?php _e( 'Variation price (required)', 'woocommerce' ); ?>" />
  63. </td>
  64. <td>
  65. <label><?php echo __( 'Sale Price:', 'woocommerce' ) . ' (' . get_woocommerce_currency_symbol() . ')'; ?> <a href="#" class="sale_schedule"><?php _e( 'Schedule', 'woocommerce' ); ?></a><a href="#" class="cancel_sale_schedule" style="display:none"><?php _e( 'Cancel schedule', 'woocommerce' ); ?></a></label>
  66. <input type="text" size="5" name="variable_sale_price[<?php echo $loop; ?>]" value="<?php if ( isset( $_sale_price ) ) echo esc_attr( $_sale_price ); ?>" class="wc_input_price" />
  67. </td>
  68. </tr>
  69. <tr class="sale_price_dates_fields" style="display:none">
  70. <td>
  71. <label><?php _e( 'Sale start date:', 'woocommerce' ) ?></label>
  72. <input type="text" class="sale_price_dates_from" name="variable_sale_price_dates_from[<?php echo $loop; ?>]" value="<?php echo ! empty( $_sale_price_dates_from ) ? date_i18n( 'Y-m-d', $_sale_price_dates_from ) : ''; ?>" placeholder="<?php echo _x( 'From&hellip;', 'placeholder', 'woocommerce' ) ?> YYYY-MM-DD" maxlength="10" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" />
  73. </td>
  74. <td>
  75. <label><?php _e( 'Sale end date:', 'woocommerce' ) ?></label>
  76. <input type="text" name="variable_sale_price_dates_to[<?php echo $loop; ?>]" value="<?php echo ! empty( $_sale_price_dates_to ) ? date_i18n( 'Y-m-d', $_sale_price_dates_to ) : ''; ?>" placeholder="<?php echo _x('To&hellip;', 'placeholder', 'woocommerce') ?> YYYY-MM-DD" maxlength="10" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" />
  77. </td>
  78. </tr>
  79. <?php if ( wc_product_weight_enabled() || wc_product_dimensions_enabled() ) : ?>
  80. <tr>
  81. <?php if ( wc_product_weight_enabled() ) : ?>
  82. <td class="hide_if_variation_virtual">
  83. <label><?php echo __( 'Weight', 'woocommerce' ) . ' (' . esc_html( get_option( 'woocommerce_weight_unit' ) ) . '):'; ?> <a class="tips" data-tip="<?php _e( 'Enter a weight for this variation or leave blank to use the parent product weight.', 'woocommerce' ); ?>" href="#">[?]</a></label>
  84. <input type="text" size="5" name="variable_weight[<?php echo $loop; ?>]" value="<?php if ( isset( $_weight ) ) echo esc_attr( $_weight ); ?>" placeholder="<?php echo esc_attr( $parent_data['weight'] ); ?>" class="wc_input_decimal" />
  85. </td>
  86. <?php else : ?>
  87. <td>&nbsp;</td>
  88. <?php endif; ?>
  89. <?php if ( wc_product_dimensions_enabled() ) : ?>
  90. <td class="dimensions_field hide_if_variation_virtual">
  91. <label for="product_length"><?php echo __( 'Dimensions (L&times;W&times;H)', 'woocommerce' ) . ' (' . esc_html( get_option( 'woocommerce_dimension_unit' ) ) . '):'; ?></label>
  92. <input id="product_length" class="input-text wc_input_decimal" size="6" type="text" name="variable_length[<?php echo $loop; ?>]" value="<?php if ( isset( $_length ) ) echo esc_attr( $_length ); ?>" placeholder="<?php echo esc_attr( $parent_data['length'] ); ?>" />
  93. <input class="input-text wc_input_decimal" size="6" type="text" name="variable_width[<?php echo $loop; ?>]" value="<?php if ( isset( $_width ) ) echo esc_attr( $_width ); ?>" placeholder="<?php echo esc_attr( $parent_data['width'] ); ?>" />
  94. <input class="input-text wc_input_decimal last" size="6" type="text" name="variable_height[<?php echo $loop; ?>]" value="<?php if ( isset( $_height ) ) echo esc_attr( $_height ); ?>" placeholder="<?php echo esc_attr( $parent_data['height'] ); ?>" />
  95. </td>
  96. <?php else : ?>
  97. <td>&nbsp;</td>
  98. <?php endif; ?>
  99. </tr>
  100. <?php endif; ?>
  101. <tr>
  102. <td class="hide_if_variation_virtual"><label><?php _e( 'Shipping class:', 'woocommerce' ); ?></label> <?php
  103. $args = array(
  104. 'taxonomy' => 'product_shipping_class',
  105. 'hide_empty' => 0,
  106. 'show_option_none' => __( 'Same as parent', 'woocommerce' ),
  107. 'name' => 'variable_shipping_class[' . $loop . ']',
  108. 'id' => '',
  109. 'selected' => isset( $shipping_class ) ? esc_attr( $shipping_class ) : '',
  110. 'echo' => 0
  111. );
  112. echo wp_dropdown_categories( $args );
  113. ?></td>
  114. <td>
  115. <?php if ( get_option( 'woocommerce_calc_taxes' ) == 'yes' ) : ?>
  116. <label><?php _e( 'Tax class:', 'woocommerce' ); ?></label>
  117. <select name="variable_tax_class[<?php echo $loop; ?>]">
  118. <option value="parent" <?php selected( is_null( $_tax_class ), true ); ?>><?php _e( 'Same as parent', 'woocommerce' ); ?></option>
  119. <?php
  120. foreach ( $parent_data['tax_class_options'] as $key => $value )
  121. echo '<option value="' . esc_attr( $key ) . '" ' . selected( $key === $_tax_class, true, false ) . '>' . esc_html( $value ) . '</option>';
  122. ?></select>
  123. <?php endif; ?>
  124. </td>
  125. </tr>
  126. <tr class="show_if_variation_downloadable" style="display:none">
  127. <td colspan="2">
  128. <div class="form-field downloadable_files">
  129. <label><?php _e( 'Downloadable Files', 'woocommerce' ); ?>:</label>
  130. <table class="widefat">
  131. <thead>
  132. <tr>
  133. <th><?php _e( 'Name', 'woocommerce' ); ?> <span class="tips" data-tip="<?php _e( 'This is the name of the download shown to the customer.', 'woocommerce' ); ?>">[?]</span></th>
  134. <th colspan="2"><?php _e( 'File URL', 'woocommerce' ); ?> <span class="tips" data-tip="<?php _e( 'This is the URL or absolute path to the file which customers will get access to.', 'woocommerce' ); ?>">[?]</span></th>
  135. <th>&nbsp;</th>
  136. </tr>
  137. </thead>
  138. <tfoot>
  139. <tr>
  140. <th colspan="4">
  141. <a href="#" class="button insert" data-row="<?php
  142. $file = array(
  143. 'file' => '',
  144. 'name' => ''
  145. );
  146. ob_start();
  147. include( 'html-product-variation-download.php' );
  148. echo esc_attr( ob_get_clean() );
  149. ?>"><?php _e( 'Add File', 'woocommerce' ); ?></a>
  150. </th>
  151. </tr>
  152. </tfoot>
  153. <tbody>
  154. <?php
  155. if ( $_downloadable_files ) {
  156. foreach ( $_downloadable_files as $key => $file ) {
  157. if ( ! is_array( $file ) ) {
  158. $file = array(
  159. 'file' => $file,
  160. 'name' => ''
  161. );
  162. }
  163. include( 'html-product-variation-download.php' );
  164. }
  165. }
  166. ?>
  167. </tbody>
  168. </table>
  169. </div>
  170. </td>
  171. </tr>
  172. <tr class="show_if_variation_downloadable">
  173. <td>
  174. <div>
  175. <label><?php _e( 'Download Limit:', 'woocommerce' ); ?> <a class="tips" data-tip="<?php _e( 'Leave blank for unlimited re-downloads.', 'woocommerce' ); ?>" href="#">[?]</a></label>
  176. <input type="number" size="5" name="variable_download_limit[<?php echo $loop; ?>]" value="<?php if ( isset( $_download_limit ) ) echo esc_attr( $_download_limit ); ?>" placeholder="<?php _e( 'Unlimited', 'woocommerce' ); ?>" step="1" min="0" />
  177. </div>
  178. </td>
  179. <td>
  180. <div>
  181. <label><?php _e( 'Download Expiry:', 'woocommerce' ); ?> <a class="tips" data-tip="<?php _e( 'Enter the number of days before a download link expires, or leave blank.', 'woocommerce' ); ?>" href="#">[?]</a></label>
  182. <input type="number" size="5" name="variable_download_expiry[<?php echo $loop; ?>]" value="<?php if ( isset( $_download_expiry ) ) echo esc_attr( $_download_expiry ); ?>" placeholder="<?php _e( 'Unlimited', 'woocommerce' ); ?>" step="1" min="0" />
  183. </div>
  184. </td>
  185. </tr>
  186. <?php do_action( 'woocommerce_product_after_variable_attributes', $loop, $variation_data, $variation ); ?>
  187. </table>
  188. </td>
  189. </tr>
  190. <tr>
  191. <td class="upload_image">
  192. <a href="#" class="upload_image_button <?php if ( $image_id > 0 ) echo 'remove'; ?>" rel="<?php echo esc_attr( $variation_id ); ?>"><img src="<?php if ( ! empty( $image ) ) echo esc_attr( $image ); else echo esc_attr( wc_placeholder_img_src() ); ?>" /><input type="hidden" name="upload_image_id[<?php echo $loop; ?>]" class="upload_image_id" value="<?php echo esc_attr( $image_id ); ?>" /><span class="overlay"></span></a>
  193. </td>
  194. <td class="options">
  195. <label><input type="checkbox" class="checkbox" name="variable_enabled[<?php echo $loop; ?>]" <?php checked( $variation_post_status, 'publish' ); ?> /> <?php _e( 'Enabled', 'woocommerce' ); ?></label>
  196. <label><input type="checkbox" class="checkbox variable_is_downloadable" name="variable_is_downloadable[<?php echo $loop; ?>]" <?php checked( isset( $_downloadable ) ? $_downloadable : '', 'yes' ); ?> /> <?php _e( 'Downloadable', 'woocommerce' ); ?> <a class="tips" data-tip="<?php _e( 'Enable this option if access is given to a downloadable file upon purchase of a product', 'woocommerce' ); ?>" href="#">[?]</a></label>
  197. <label><input type="checkbox" class="checkbox variable_is_virtual" name="variable_is_virtual[<?php echo $loop; ?>]" <?php checked( isset( $_virtual ) ? $_virtual : '', 'yes' ); ?> /> <?php _e( 'Virtual', 'woocommerce' ); ?> <a class="tips" data-tip="<?php _e( 'Enable this option if a product is not shipped or there is no shipping cost', 'woocommerce' ); ?>" href="#">[?]</a></label>
  198. <?php do_action( 'woocommerce_variation_options', $loop, $variation_data, $variation ); ?>
  199. </td>
  200. </tr>
  201. </tbody>
  202. </table>
  203. </div>