woocommerce
/
src
/
Internal
/
StockNotifications
/
Admin
/
Templates
/
html-admin-notification-create.php
html-admin-notification-create.php
1 month ago
html-admin-notification-edit.php
10 months ago
html-admin-notifications.php
10 months ago
html-product-data-admin.php
10 months ago
html-admin-notification-create.php
157 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Admin View: Notification create |
| 4 | * |
| 5 | * @since 10.2.0 |
| 6 | */ |
| 7 | |
| 8 | declare( strict_types = 1 ); |
| 9 | |
| 10 | if ( ! defined( 'ABSPATH' ) ) { |
| 11 | exit; |
| 12 | } |
| 13 | |
| 14 | use Automattic\WooCommerce\Internal\StockNotifications\Admin\NotificationsPage; |
| 15 | ?> |
| 16 | <div class="wrap woocommerce-customer-stock-notifications"> |
| 17 | |
| 18 | <h1 class="wp-heading-inline"><?php esc_html_e( 'Add Notification', 'woocommerce' ); ?></h1> |
| 19 | <a href="<?php echo esc_url( NotificationsPage::PAGE_URL ); ?>" class="page-title-action"><?php esc_html_e( 'View All', 'woocommerce' ); ?></a> |
| 20 | |
| 21 | <hr class="wp-header-end"> |
| 22 | |
| 23 | <form method="POST" id="edit-notification-form"> |
| 24 | <?php wp_nonce_field( 'woocommerce-customer-stock-notification-create', 'customer_stock_notification_create_security' ); ?> |
| 25 | |
| 26 | <div id="poststuff"> |
| 27 | <div id="post-body" class="columns-2"> |
| 28 | |
| 29 | <!-- SIDEBAR --> |
| 30 | <div id="postbox-container-1" class="postbox-container"> |
| 31 | |
| 32 | <div id="woocommerce-order-actions" class="postbox"> |
| 33 | |
| 34 | <h2 class="hndle ui-sortable-handle"><span><?php esc_html_e( 'Notification actions', 'woocommerce' ); ?></span></h2> |
| 35 | |
| 36 | <div class="inside"> |
| 37 | <ul class="order_actions submitbox"> |
| 38 | |
| 39 | <li class="wide" id="actions"> |
| 40 | <select name="wc_customer_stock_notification_action" disabled="disabled"> |
| 41 | <option value=""><?php esc_html_e( 'Choose an action...', 'woocommerce' ); ?></option> |
| 42 | </select> |
| 43 | <button class="button wc-reload" disabled="disabled"><span><?php esc_html_e( 'Apply', 'woocommerce' ); ?></span></button> |
| 44 | </li> |
| 45 | |
| 46 | <li class="wide"> |
| 47 | <button type="submit" class="button save_order button-primary" name="save" value="<?php esc_attr_e( 'Create', 'woocommerce' ); ?>"><?php esc_html_e( 'Create', 'woocommerce' ); ?></button> |
| 48 | </li> |
| 49 | |
| 50 | </ul> |
| 51 | </div> |
| 52 | |
| 53 | </div><!-- .postbox --> |
| 54 | |
| 55 | </div><!-- #container1 --> |
| 56 | |
| 57 | <!-- MAIN --> |
| 58 | <div id="postbox-container-2" class="postbox-container"> |
| 59 | |
| 60 | <div id="notification-data" class="postbox notification-data notification-data--create"> |
| 61 | <div class="notification-data__row notification-data__row--columns"> |
| 62 | |
| 63 | <div class="notification-data__header-column"> |
| 64 | |
| 65 | <h2 class="notification-data__header"> |
| 66 | <?php esc_html_e( 'Notification details', 'woocommerce' ); ?> |
| 67 | </h2> |
| 68 | |
| 69 | </div> |
| 70 | |
| 71 | </div><!-- #row --> |
| 72 | |
| 73 | <div class="notification-data__row notification-data__row--columns"> |
| 74 | |
| 75 | <div class="notification-data__form-field"> |
| 76 | <label><?php esc_html_e( 'Customer', 'woocommerce' ); ?></label> |
| 77 | <?php |
| 78 | $user_string = ''; |
| 79 | $user_id = 0; |
| 80 | |
| 81 | // phpcs:disable WordPress.Security.NonceVerification.Recommended |
| 82 | if ( ! empty( $_REQUEST['user_id'] ) ) { |
| 83 | |
| 84 | $user_id = absint( wp_unslash( $_REQUEST['user_id'] ) ); |
| 85 | if ( $user_id > 0 ) { |
| 86 | $user = get_user_by( 'id', absint( $user_id ) ); |
| 87 | if ( $user ) { |
| 88 | $user_string = sprintf( |
| 89 | /* translators: 1: user display name 2: user ID 3: user email */ |
| 90 | esc_html__( '%1$s (#%2$s – %3$s)', 'woocommerce' ), |
| 91 | $user->display_name, |
| 92 | absint( $user->ID ), |
| 93 | $user->user_email |
| 94 | ); |
| 95 | } |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | $email = isset( $_REQUEST['user_email'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['user_email'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 100 | ?> |
| 101 | <select class="wc-customer-search" name="user_id" data-placeholder="<?php esc_attr_e( 'Search for a customer…', 'woocommerce' ); ?>" data-allow_clear="true"> |
| 102 | <?php if ( $user_string && $user_id ) { ?> |
| 103 | <option value="<?php echo esc_attr( $user_id ); ?>" selected="selected"><?php echo wp_kses_post( htmlspecialchars( $user_string, ENT_COMPAT ) ); ?></option> |
| 104 | <?php } ?> |
| 105 | </select> |
| 106 | <div class="divider"></div> |
| 107 | <span class="or_relation_label"><?php esc_html_e( '— or —', 'woocommerce' ); ?></span> |
| 108 | <input type="email" class="or_relation_label__input" placeholder="<?php esc_html_e( 'Enter customer e-mail…', 'woocommerce' ); ?>" name="user_email" value="<?php echo esc_attr( $email ); ?>"/> |
| 109 | |
| 110 | <div class="wp-clearfix"></div> |
| 111 | </div> |
| 112 | |
| 113 | <div class="notification-data__form-field"> |
| 114 | |
| 115 | <label><?php esc_html_e( 'Product', 'woocommerce' ); ?></label> |
| 116 | <?php |
| 117 | $product_string = ''; |
| 118 | $product_id = 0; |
| 119 | |
| 120 | // phpcs:disable WordPress.Security.NonceVerification.Recommended |
| 121 | if ( ! empty( $_REQUEST['product_id'] ) ) { |
| 122 | |
| 123 | $product_id = absint( wp_unslash( $_REQUEST['product_id'] ) ); |
| 124 | if ( $product_id > 0 ) { |
| 125 | $product = wc_get_product( $product_id ); |
| 126 | if ( is_a( $product, 'WC_Product' ) ) { |
| 127 | $product_string = sprintf( |
| 128 | /* translators: 1: product title 2: product ID */ |
| 129 | esc_html__( '%1$s (#%2$s)', 'woocommerce' ), |
| 130 | $product->get_parent_id() ? $product->get_name() : $product->get_title(), |
| 131 | absint( $product->get_id() ) |
| 132 | ); |
| 133 | } |
| 134 | } |
| 135 | } |
| 136 | // phpcs:enable WordPress.Security.NonceVerification.Recommended |
| 137 | $excluded_product_types = array_diff( array_keys( wc_get_product_types() ), array( 'simple', 'variable' ) ); |
| 138 | ?> |
| 139 | <select class="wc-product-search" name="product_id" data-action="woocommerce_json_search_products_and_variations" data-exclude_type="<?php echo esc_attr( implode( ',', $excluded_product_types ) ); ?>" data-display_stock="true" data-placeholder="<?php esc_attr_e( 'Select product…', 'woocommerce' ); ?>" data-allow_clear="true"> |
| 140 | <?php if ( $product_string && $product_id ) { ?> |
| 141 | <option value="<?php echo esc_attr( $product_id ); ?>" selected="selected"><?php echo wp_kses_post( htmlspecialchars( $product_string, ENT_COMPAT ) ); ?></option> |
| 142 | <?php } ?> |
| 143 | </select> |
| 144 | </div> |
| 145 | |
| 146 | </div><!-- #row --> |
| 147 | |
| 148 | </div><!-- .postbox --> |
| 149 | |
| 150 | </div><!-- #container2 --> |
| 151 | |
| 152 | </div><!-- #post-body --> |
| 153 | </div> |
| 154 | |
| 155 | </form> |
| 156 | |
| 157 | </div> |