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-general.php
263 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Product general data panel. |
| 4 | * |
| 5 | * @package WooCommerce\Admin |
| 6 | */ |
| 7 | |
| 8 | use Automattic\WooCommerce\Internal\CostOfGoodsSold\CostOfGoodsSoldController; |
| 9 | |
| 10 | defined( 'ABSPATH' ) || exit; |
| 11 | |
| 12 | use Automattic\WooCommerce\Enums\ProductTaxStatus; |
| 13 | |
| 14 | ?> |
| 15 | <div id="general_product_data" class="panel woocommerce_options_panel"> |
| 16 | |
| 17 | <div class="options_group show_if_external"> |
| 18 | <?php |
| 19 | woocommerce_wp_text_input( |
| 20 | array( |
| 21 | 'id' => '_product_url', |
| 22 | 'value' => is_callable( array( $product_object, 'get_product_url' ) ) ? $product_object->get_product_url( 'edit' ) : '', |
| 23 | 'label' => __( 'Product URL', 'woocommerce' ), |
| 24 | 'placeholder' => 'https://', |
| 25 | 'description' => __( 'Enter the external URL to the product.', 'woocommerce' ), |
| 26 | ) |
| 27 | ); |
| 28 | |
| 29 | woocommerce_wp_text_input( |
| 30 | array( |
| 31 | 'id' => '_button_text', |
| 32 | 'value' => is_callable( array( $product_object, 'get_button_text' ) ) ? $product_object->get_button_text( 'edit' ) : '', |
| 33 | 'label' => __( 'Button text', 'woocommerce' ), |
| 34 | 'placeholder' => _x( 'Buy product', 'placeholder', 'woocommerce' ), |
| 35 | 'description' => __( 'This text will be shown on the button linking to the external product.', 'woocommerce' ), |
| 36 | ) |
| 37 | ); |
| 38 | |
| 39 | do_action( 'woocommerce_product_options_external' ); |
| 40 | ?> |
| 41 | </div> |
| 42 | |
| 43 | <?php |
| 44 | $cogs_controller = wc_get_container()->get( CostOfGoodsSoldController::class ); |
| 45 | $cogs_is_enabled = $cogs_controller->feature_is_enabled(); |
| 46 | ?> |
| 47 | <div class="options_group pricing show_if_simple show_if_external hidden<?php echo $cogs_is_enabled ? ' show_if_variable' : ''; ?>"> |
| 48 | <?php if ( $cogs_is_enabled ) : ?> |
| 49 | <span class="show_if_simple show_if_external"> |
| 50 | <?php endif; ?> |
| 51 | <?php |
| 52 | $tax_label = ''; |
| 53 | if ( wc_tax_enabled() ) { |
| 54 | $tax_text = wc_prices_include_tax() |
| 55 | ? __( 'incl. tax', 'woocommerce' ) |
| 56 | : __( 'ex. tax', 'woocommerce' ); |
| 57 | $tax_label = ' (' . $tax_text . ')'; |
| 58 | } |
| 59 | |
| 60 | woocommerce_wp_text_input( |
| 61 | array( |
| 62 | 'id' => '_regular_price', |
| 63 | 'value' => $product_object->get_regular_price( 'edit' ), |
| 64 | 'label' => __( 'Regular price', 'woocommerce' ) . ' (' . get_woocommerce_currency_symbol() . ')' . $tax_label, |
| 65 | 'data_type' => 'price', |
| 66 | ) |
| 67 | ); |
| 68 | |
| 69 | woocommerce_wp_text_input( |
| 70 | array( |
| 71 | 'id' => '_sale_price', |
| 72 | 'value' => $product_object->get_sale_price( 'edit' ), |
| 73 | 'data_type' => 'price', |
| 74 | 'label' => __( 'Sale price', 'woocommerce' ) . ' (' . get_woocommerce_currency_symbol() . ')' . $tax_label, |
| 75 | 'description' => '<a href="#" class="sale_schedule">' . __( 'Schedule', 'woocommerce' ) . '</a>', |
| 76 | ) |
| 77 | ); |
| 78 | |
| 79 | $sale_price_dates_from_timestamp = $product_object->get_date_on_sale_from( 'edit' ) ? $product_object->get_date_on_sale_from( 'edit' )->getOffsetTimestamp() : false; |
| 80 | $sale_price_dates_to_timestamp = $product_object->get_date_on_sale_to( 'edit' ) ? $product_object->get_date_on_sale_to( 'edit' )->getOffsetTimestamp() : false; |
| 81 | |
| 82 | $sale_price_dates_from = $sale_price_dates_from_timestamp ? date_i18n( 'Y-m-d', $sale_price_dates_from_timestamp ) : ''; |
| 83 | $sale_price_dates_to = $sale_price_dates_to_timestamp ? date_i18n( 'Y-m-d', $sale_price_dates_to_timestamp ) : ''; |
| 84 | |
| 85 | // phpcs:disable WooCommerce.Commenting.CommentHooks.MissingSinceComment |
| 86 | |
| 87 | /** |
| 88 | * Hook to customize the regular expression that validates dates entered in the WooCommerce admin editors. |
| 89 | * |
| 90 | * @param string $pattern Default pattern to use. |
| 91 | */ |
| 92 | $date_input_html_pattern = apply_filters( 'woocommerce_date_input_html_pattern', '[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])' ); |
| 93 | |
| 94 | echo '<p class="form-field sale_price_dates_fields"> |
| 95 | <label for="_sale_price_dates_from">' . esc_html__( 'Sale price dates', 'woocommerce' ) . '</label> |
| 96 | <input type="text" class="short" name="_sale_price_dates_from" id="_sale_price_dates_from" value="' . esc_attr( $sale_price_dates_from ) . '" placeholder="' . esc_html( _x( 'From…', 'placeholder', 'woocommerce' ) ) . ' YYYY-MM-DD" maxlength="10" pattern="' . esc_attr( $date_input_html_pattern ) . '" /> |
| 97 | <input type="text" class="short" name="_sale_price_dates_to" id="_sale_price_dates_to" value="' . esc_attr( $sale_price_dates_to ) . '" placeholder="' . esc_html( _x( 'To…', 'placeholder', 'woocommerce' ) ) . ' YYYY-MM-DD" maxlength="10" pattern="' . esc_attr( $date_input_html_pattern ) . '" /> |
| 98 | <a href="#" class="description cancel_sale_schedule">' . esc_html__( 'Cancel', 'woocommerce' ) . '</a>' . wc_help_tip( __( 'The sale will start at 00:00:00 of "From" date and end at 23:59:59 of "To" date.', 'woocommerce' ) ) . ' |
| 99 | </p>'; |
| 100 | |
| 101 | /** |
| 102 | * Action that allows to render additional fields for price related settings in the product editor. |
| 103 | */ |
| 104 | do_action( 'woocommerce_product_options_pricing' ); |
| 105 | |
| 106 | // phpcs:enable WooCommerce.Commenting.CommentHooks.MissingSinceComment |
| 107 | ?> |
| 108 | <?php if ( $cogs_is_enabled ) : ?> |
| 109 | </span> |
| 110 | <?php endif; ?> |
| 111 | <?php if ( $cogs_is_enabled ) : ?> |
| 112 | <span class="show_if_simple show_if_variable show_if_external hidden"> |
| 113 | <?php |
| 114 | $is_variable = $product_object instanceof WC_Product_Variable; |
| 115 | |
| 116 | woocommerce_wp_text_input( |
| 117 | array( |
| 118 | 'id' => '_cogs_value', |
| 119 | 'value' => $product_object->get_cogs_value() ?? '', |
| 120 | 'label' => __( 'Cost of goods', 'woocommerce' ) . ' (' . get_woocommerce_currency_symbol() . ')', |
| 121 | 'data_type' => 'price', |
| 122 | 'desc_tip' => 'true', |
| 123 | 'placeholder' => '0', |
| 124 | 'description' => $cogs_controller->get_general_cost_edit_field_tooltip( $is_variable ), |
| 125 | ) |
| 126 | ); |
| 127 | ?> |
| 128 | </span> |
| 129 | <?php endif; ?> |
| 130 | </div> |
| 131 | |
| 132 | <div class="options_group show_if_downloadable hidden"> |
| 133 | <div class="form-field downloadable_files"> |
| 134 | <label><?php esc_html_e( 'Downloadable files', 'woocommerce' ); ?></label> |
| 135 | <table class="widefat"> |
| 136 | <thead> |
| 137 | <tr> |
| 138 | <th class="sort"> </th> |
| 139 | <th><?php esc_html_e( 'Name', 'woocommerce' ); ?> <?php echo wc_help_tip( __( 'This is the name of the download shown to the customer.', 'woocommerce' ) ); ?></th> |
| 140 | <th colspan="2"><?php esc_html_e( 'File URL', 'woocommerce' ); ?> <?php echo wc_help_tip( __( 'This is the URL or absolute path to the file which customers will get access to. URLs entered here should already be encoded.', 'woocommerce' ) ); ?></th> |
| 141 | <th> </th> |
| 142 | </tr> |
| 143 | </thead> |
| 144 | <tbody> |
| 145 | <?php |
| 146 | $downloadable_files = $product_object->get_downloads( 'edit' ); |
| 147 | $disabled_downloads_count = 0; |
| 148 | |
| 149 | if ( $downloadable_files ) { |
| 150 | foreach ( $downloadable_files as $key => $file ) { |
| 151 | $disabled_download = isset( $file['enabled'] ) && false === $file['enabled']; |
| 152 | $disabled_downloads_count += (int) $disabled_download; |
| 153 | include __DIR__ . '/html-product-download.php'; |
| 154 | } |
| 155 | } |
| 156 | ?> |
| 157 | </tbody> |
| 158 | <tfoot> |
| 159 | <tr> |
| 160 | <th colspan="2"> |
| 161 | <a href="#" class="button insert" data-row=" |
| 162 | <?php |
| 163 | $key = ''; |
| 164 | $file = array( |
| 165 | 'file' => '', |
| 166 | 'name' => '', |
| 167 | ); |
| 168 | $disabled_download = false; |
| 169 | ob_start(); |
| 170 | require __DIR__ . '/html-product-download.php'; |
| 171 | echo esc_attr( ob_get_clean() ); |
| 172 | ?> |
| 173 | "><?php esc_html_e( 'Add File', 'woocommerce' ); ?></a> |
| 174 | </th> |
| 175 | <th colspan="3"> |
| 176 | <?php if ( $disabled_downloads_count ) : ?> |
| 177 | <span class="disabled">*</span> |
| 178 | <?php |
| 179 | printf( |
| 180 | /* translators: 1: opening link tag, 2: closing link tag. */ |
| 181 | esc_html__( 'The indicated downloads have been disabled (invalid location or filetype—%1$slearn more%2$s).', 'woocommerce' ), |
| 182 | '<a href="https://woocommerce.com/document/approved-download-directories" target="_blank">', |
| 183 | '</a>' |
| 184 | ); |
| 185 | ?> |
| 186 | <?php endif; ?> |
| 187 | </th> |
| 188 | </tr> |
| 189 | </tfoot> |
| 190 | </table> |
| 191 | </div> |
| 192 | <?php |
| 193 | woocommerce_wp_text_input( |
| 194 | array( |
| 195 | 'id' => '_download_limit', |
| 196 | 'value' => -1 === $product_object->get_download_limit( 'edit' ) ? '' : $product_object->get_download_limit( 'edit' ), |
| 197 | 'label' => __( 'Download limit', 'woocommerce' ), |
| 198 | 'placeholder' => __( 'Unlimited', 'woocommerce' ), |
| 199 | 'description' => __( 'Leave blank for unlimited re-downloads.', 'woocommerce' ), |
| 200 | 'type' => 'number', |
| 201 | 'custom_attributes' => array( |
| 202 | 'step' => '1', |
| 203 | 'min' => '0', |
| 204 | ), |
| 205 | ) |
| 206 | ); |
| 207 | |
| 208 | woocommerce_wp_text_input( |
| 209 | array( |
| 210 | 'id' => '_download_expiry', |
| 211 | 'value' => -1 === $product_object->get_download_expiry( 'edit' ) ? '' : $product_object->get_download_expiry( 'edit' ), |
| 212 | 'label' => __( 'Download expiry', 'woocommerce' ), |
| 213 | 'placeholder' => __( 'Never', 'woocommerce' ), |
| 214 | 'description' => __( 'Enter the number of days before a download link expires, or leave blank.', 'woocommerce' ), |
| 215 | 'type' => 'number', |
| 216 | 'custom_attributes' => array( |
| 217 | 'step' => '1', |
| 218 | 'min' => '0', |
| 219 | ), |
| 220 | ) |
| 221 | ); |
| 222 | |
| 223 | do_action( 'woocommerce_product_options_downloads' ); |
| 224 | ?> |
| 225 | </div> |
| 226 | |
| 227 | <?php if ( wc_tax_enabled() ) : ?> |
| 228 | <div class="options_group show_if_simple show_if_external show_if_variable"> |
| 229 | <?php |
| 230 | woocommerce_wp_select( |
| 231 | array( |
| 232 | 'id' => '_tax_status', |
| 233 | 'value' => $product_object->get_tax_status( 'edit' ), |
| 234 | 'label' => __( 'Tax status', 'woocommerce' ), |
| 235 | 'options' => array( |
| 236 | ProductTaxStatus::TAXABLE => __( 'Taxable', 'woocommerce' ), |
| 237 | ProductTaxStatus::SHIPPING => __( 'Shipping only', 'woocommerce' ), |
| 238 | ProductTaxStatus::NONE => _x( 'None', 'Tax status', 'woocommerce' ), |
| 239 | ), |
| 240 | 'desc_tip' => 'true', |
| 241 | 'description' => __( 'Define whether or not the entire product is taxable, or just the cost of shipping it.', 'woocommerce' ), |
| 242 | ) |
| 243 | ); |
| 244 | |
| 245 | woocommerce_wp_select( |
| 246 | array( |
| 247 | 'id' => '_tax_class', |
| 248 | 'value' => $product_object->get_tax_class( 'edit' ), |
| 249 | 'label' => __( 'Tax class', 'woocommerce' ), |
| 250 | 'options' => wc_get_product_tax_class_options(), |
| 251 | 'desc_tip' => 'true', |
| 252 | 'description' => __( 'Choose a tax class for this product. Tax classes are used to apply different tax rates specific to certain types of product.', 'woocommerce' ), |
| 253 | ) |
| 254 | ); |
| 255 | |
| 256 | do_action( 'woocommerce_product_options_tax' ); |
| 257 | ?> |
| 258 | </div> |
| 259 | <?php endif; ?> |
| 260 | |
| 261 | <?php do_action( 'woocommerce_product_options_general_product_data' ); ?> |
| 262 | </div> |
| 263 |