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-linked-products.php
94 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Linked product options. |
| 4 | * |
| 5 | * @package WooCommerce\Admin |
| 6 | */ |
| 7 | |
| 8 | use Automattic\WooCommerce\Enums\ProductType; |
| 9 | |
| 10 | defined( 'ABSPATH' ) || exit; |
| 11 | |
| 12 | // In WP 7.0, we made the inputs wider. |
| 13 | // @see https://github.com/woocommerce/woocommerce/pull/63779/changes#diff-dfef13b204157e98982fb3af978fbabfaa7f6bedd31bf02f2c9070718d59642eR8402-R8408. |
| 14 | $version = get_bloginfo( 'version' ); |
| 15 | |
| 16 | if ( $version ) { |
| 17 | $version_parts = explode( '-', $version ); |
| 18 | $version = count( $version_parts ) > 1 ? $version_parts[0] : $version; |
| 19 | } |
| 20 | |
| 21 | $width = $version && version_compare( $version, '7.0', '>=' ) ? 'width: 55%;' : 'width: 50%;'; |
| 22 | ?> |
| 23 | <div id="linked_product_data" class="panel woocommerce_options_panel hidden"> |
| 24 | |
| 25 | <div class="options_group show_if_grouped"> |
| 26 | <p class="form-field"> |
| 27 | <label for="grouped_products"><?php esc_html_e( 'Grouped products', 'woocommerce' ); ?></label> |
| 28 | <select class="wc-product-search" multiple="multiple" style="<?php echo esc_attr( $width ); ?>" id="grouped_products" name="grouped_products[]" data-sortable="true" data-placeholder="<?php esc_attr_e( 'Search for a product…', 'woocommerce' ); ?>" data-action="woocommerce_json_search_products" data-exclude="<?php echo intval( $post->ID ); ?>"> |
| 29 | <?php |
| 30 | $product_ids = $product_object->is_type( ProductType::GROUPED ) ? $product_object->get_children( 'edit' ) : array(); |
| 31 | |
| 32 | if ( ! empty( $product_ids ) ) { |
| 33 | // Prime caches to reduce future queries. |
| 34 | _prime_post_caches( $product_ids ); |
| 35 | } |
| 36 | |
| 37 | foreach ( $product_ids as $product_id ) { |
| 38 | $product = wc_get_product( $product_id ); |
| 39 | if ( is_object( $product ) ) { |
| 40 | echo '<option value="' . esc_attr( $product_id ) . '"' . selected( true, true, false ) . '>' . esc_html( wp_strip_all_tags( $product->get_formatted_name() ) ) . '</option>'; |
| 41 | } |
| 42 | } |
| 43 | ?> |
| 44 | </select> <?php echo wc_help_tip( __( 'This lets you choose which products are part of this group.', 'woocommerce' ) ); // WPCS: XSS ok. ?> |
| 45 | </p> |
| 46 | </div> |
| 47 | |
| 48 | <div class="options_group"> |
| 49 | <p class="form-field"> |
| 50 | <label for="upsell_ids"><?php esc_html_e( 'Upsells', 'woocommerce' ); ?></label> |
| 51 | <select class="wc-product-search" multiple="multiple" style="<?php echo esc_attr( $width ); ?>" id="upsell_ids" name="upsell_ids[]" data-placeholder="<?php esc_attr_e( 'Search for a product…', 'woocommerce' ); ?>" data-action="woocommerce_json_search_products_and_variations" data-exclude="<?php echo intval( $post->ID ); ?>"> |
| 52 | <?php |
| 53 | $product_ids = $product_object->get_upsell_ids( 'edit' ); |
| 54 | |
| 55 | if ( ! empty( $product_ids ) ) { |
| 56 | // Prime caches to reduce future queries. |
| 57 | _prime_post_caches( $product_ids ); |
| 58 | } |
| 59 | |
| 60 | foreach ( $product_ids as $product_id ) { |
| 61 | $product = wc_get_product( $product_id ); |
| 62 | if ( is_object( $product ) ) { |
| 63 | echo '<option value="' . esc_attr( $product_id ) . '"' . selected( true, true, false ) . '>' . esc_html( wp_strip_all_tags( $product->get_formatted_name() ) ) . '</option>'; |
| 64 | } |
| 65 | } |
| 66 | ?> |
| 67 | </select> <?php echo wc_help_tip( __( 'Upsells are products which you recommend instead of the currently viewed product, for example, products that are more profitable or better quality or more expensive.', 'woocommerce' ) ); // WPCS: XSS ok. ?> |
| 68 | </p> |
| 69 | |
| 70 | <p class="form-field hide_if_grouped hide_if_external"> |
| 71 | <label for="crosssell_ids"><?php esc_html_e( 'Cross-sells', 'woocommerce' ); ?></label> |
| 72 | <select class="wc-product-search" multiple="multiple" style="<?php echo esc_attr( $width ); ?>" id="crosssell_ids" name="crosssell_ids[]" data-placeholder="<?php esc_attr_e( 'Search for a product…', 'woocommerce' ); ?>" data-action="woocommerce_json_search_products_and_variations" data-exclude="<?php echo intval( $post->ID ); ?>"> |
| 73 | <?php |
| 74 | $product_ids = $product_object->get_cross_sell_ids( 'edit' ); |
| 75 | |
| 76 | if ( ! empty( $product_ids ) ) { |
| 77 | // Prime caches to reduce future queries. |
| 78 | _prime_post_caches( $product_ids ); |
| 79 | } |
| 80 | |
| 81 | foreach ( $product_ids as $product_id ) { |
| 82 | $product = wc_get_product( $product_id ); |
| 83 | if ( is_object( $product ) ) { |
| 84 | echo '<option value="' . esc_attr( $product_id ) . '"' . selected( true, true, false ) . '>' . esc_html( wp_strip_all_tags( $product->get_formatted_name() ) ) . '</option>'; |
| 85 | } |
| 86 | } |
| 87 | ?> |
| 88 | </select> <?php echo wc_help_tip( __( 'Cross-sells are products which you promote in the cart, based on the current product.', 'woocommerce' ) ); // WPCS: XSS ok. ?> |
| 89 | </p> |
| 90 | </div> |
| 91 | |
| 92 | <?php do_action( 'woocommerce_product_options_related' ); ?> |
| 93 | </div> |
| 94 |