PluginProbe
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant / 1.10.1
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant v1.10.1
2.3.2 2.3.1 2.3.0 2.2.8 2.2.7 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.11.0 1.11.1 1.11.2 1.6 1.7 1.8 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 1.9.10 1.9.11 All 60 releases
merchant / templates / modules / frequently-bought-together / single-product.php

single-product.php in Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant 1.10.1, at templates/modules/frequently-bought-together/single-product.php

133 lines 8.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Template for frequently bought together module content on single product.
4 *
5 * @var $args array template args
6 *
7 * @since 1.0
8 */
9
10 if ( ! defined( 'ABSPATH' ) ) {
11 exit; // Exit if accessed directly
12 }
13 if ( empty( $args['bundles'] ) ) {
14 return;
15 }
16 ?>
17 <div class="merchant-frequently-bought-together">
18 <div class="merchant-frequently-bought-together-bundles" data-nonce="<?php echo isset( $args['nonce'] ) ? esc_attr( $args['nonce'] ) : '' ?>" data-cart-url="<?php echo esc_attr( wc_get_cart_url() ) ?>">
19 <?php foreach($args['bundles'] as $parent_id => $bundles ) : ?>
20 <?php foreach ( $bundles as $key => $bundle ) :
21 $bundle_has_variable_product = false;
22 $discount_type = isset( $bundle['discount_type'] ) ? $bundle['discount_type'] : '';
23 $discount_value = isset( $bundle['discount_value'] ) ? $bundle['discount_value'] : 0;
24 $has_no_discount = $discount_value <= 0;
25 if ( ! isset( $bundle['enable_discount'] ) ) {
26 $has_no_discount = true;
27 $bundle['discount_value'] = 0;
28 }
29 ?>
30 <?php if ( empty( $bundle['products'] ) ) continue ?>
31 <h3 class="merchant-frequently-bought-together-title">
32 <?php echo isset( $bundle['product_single_page']['title'] ) ? esc_html( Merchant_Translator::translate( $bundle['product_single_page']['title'] ) ) : esc_html__( 'Frequently Bought Together', 'merchant' ) ?>
33 </h3>
34 <div class="merchant-frequently-bought-together-bundle<?php echo ( $has_no_discount ) ? ' has-no-discount' : ''; ?>">
35 <form class="merchant-frequently-bought-together-form" data-product="<?php echo esc_attr( isset( $bundle['product_to_display'] ) ? $bundle['product_to_display'] : $parent_id ) ?>" data-bundle="<?php echo esc_attr( $key ); ?>" data-bundle-discount-type="<?php echo esc_attr( $discount_type ); ?>" data-bundle-discount-value="<?php echo esc_attr( $discount_value ); ?>">
36 <div class="merchant-frequently-bought-together-bundle-products">
37 <?php foreach ( $bundle['products'] as $product_key => $product ) :
38 $is_variable_product = isset( $product['type'] ) && 'variable' === $product['type'] ? true : false;
39
40 if( $is_variable_product ) {
41 $bundle_has_variable_product = true;
42 }
43
44 ?>
45 <div class="merchant-frequently-bought-together-bundle-product<?php echo $is_variable_product ? ' is-variable' : ''; ?>" data-product="<?php echo esc_attr( $product['id'] ) ?>" data-key="<?php echo esc_attr( $product_key ) ?>" data-product-price="<?php echo esc_attr( $product['price'] ); ?>" style="<?php
46 echo isset( $bundle['product_single_page']['bundle_border_radius'] ) ? esc_attr( 'border-radius: ' . $bundle['product_single_page']['bundle_border_radius'] . 'px;' ) : '';
47 echo isset( $bundle['product_single_page']['bundle_border_color'] ) ? esc_attr( 'border-color: ' . $bundle['product_single_page']['bundle_border_color'] . ';' ) : ''; ?>">
48 <?php echo wp_kses_post( $product['image'] ); ?>
49 <div class="merchant-frequently-bought-together-bundle-product-contents">
50 <p class="woocommerce-loop-product__title">
51 <a href="<?php echo esc_url( $product['permalink'] ); ?>" target="_blank">
52 <?php echo esc_html( $product['title'] ); ?>
53 </a>
54 </p>
55 <div class="merchant-frequently-bought-together-bundle-product-price">
56 <?php echo wp_kses( $product['price_html'], merchant_kses_allowed_tags( array( 'bdi' ) ) ); ?>
57 </div>
58 <?php if ( isset( $product['attributes'] ) && ! empty( $product['attributes'] ) ) : ?>
59 <div class="merchant-frequently-bought-together-bundle-product-attributes" data-nonce="<?php echo esc_attr( wp_create_nonce( 'mrc_get_variation_data_nonce' ) ); ?>">
60 <?php foreach ( $product['attributes'] as $attr_key => $attribute ) : ?>
61 <select name="<?php echo esc_attr( $attr_key ) ?>" required>
62 <option value="">
63 <?php echo esc_html(
64 /* Translators: 1. Attribute label */
65 sprintf( __( 'Select %s', 'merchant' ), $attribute['label'] )
66 ); ?>
67 </option>
68 <?php foreach ( $attribute['terms'] as $_term ) : ?>
69 <option value="<?php echo esc_attr( $_term['slug'] ) ?>" <?php selected( $_term['selected'], true, true ); ?>><?php echo esc_html( $_term['name'] ) ?></option>
70 <?php endforeach; ?>
71 </select>
72 <?php endforeach; ?>
73 </div>
74 <?php endif; ?>
75 </div>
76 <?php if ( $product_key !== ( count( $bundle['products'] ) - 1 ) ) : ?>
77 <div class="merchant-frequently-bought-together-bundle-product-plus" style="<?php
78 echo isset( $bundle['product_single_page']['plus_bg_color'] ) ? esc_attr( 'background-color: ' . $bundle['product_single_page']['plus_bg_color'] . ';' ) : '';
79 echo isset( $bundle['product_single_page']['plus_text_color'] ) ? esc_attr( 'color: ' . $bundle['product_single_page']['plus_text_color'] . ';' ) : ''; ?>">+</div>
80 <?php endif; ?>
81 </div>
82 <?php endforeach; ?>
83 </div>
84 <div class="merchant-frequently-bought-together-bundle-offer">
85 <p class="merchant-frequently-bought-together-bundle-total">
86 <?php echo isset( $bundle['product_single_page']['price_label'] ) ? esc_html( Merchant_Translator::translate( $bundle['product_single_page']['price_label'] ) ) : esc_html__( 'Bundle price', 'merchant' ); ?>
87 </p>
88 <?php if ( $bundle_has_variable_product ) : ?>
89 <?php
90 if ( $has_no_discount ) : ?>
91 <p class="merchant-frequently-bought-together-bundle-variable-default-message"><?php
92 echo isset( $bundle['product_single_page']['no_variation_selected_text_has_no_discount'] )
93 ? esc_html( Merchant_Translator::translate( $bundle['product_single_page']['no_variation_selected_text_has_no_discount'] ) ) : esc_html__( 'Please select an option to see the total price.', 'merchant' ); ?></p>
94 <?php
95 else : ?>
96 <p class="merchant-frequently-bought-together-bundle-variable-default-message"><?php
97 echo isset( $bundle['product_single_page']['no_variation_selected_text'] ) ? esc_html( Merchant_Translator::translate( $bundle['product_single_page']['no_variation_selected_text'] ) )
98 : esc_html__( 'Please select an option to see your savings.', 'merchant' ); ?></p>
99 <?php
100 endif; ?>
101 <?php endif; ?>
102
103 <p class="merchant-frequently-bought-together-bundle-total-price price<?php echo $bundle_has_variable_product ? ' merchant-hidden' : ''; ?>">
104 <?php if ( $has_no_discount ) : ?>
105 <ins class="mrc-fbt-total-price"><?php echo wp_kses( wc_price( $bundle['total_price'] ), merchant_kses_allowed_tags( array( 'bdi' ) ) ); ?></ins>
106 <?php else : ?>
107 <del class="mrc-fbt-total-price" aria-hidden="true"><?php echo wp_kses( wc_price( $bundle['total_price'] ), merchant_kses_allowed_tags( array( 'bdi' ) ) ); ?></del>
108 <ins class="mrc-fbt-total-discounted-price"><?php echo wp_kses( wc_price( $bundle['total_discounted_price'] ), merchant_kses_allowed_tags( array( 'bdi' ) ) ); ?></ins>
109 <?php endif; ?>
110 </p>
111 <?php if ( ! $has_no_discount ) : ?>
112 <p class="merchant-frequently-bought-together-bundle-save<?php echo $bundle_has_variable_product ? ' merchant-hidden' : ''; ?>">
113 <?php echo isset( $bundle['product_single_page']['save_label'] )
114 ? wp_kses( str_replace( '{amount}', wc_price( $bundle['total_discount'] ), Merchant_Translator::translate( $bundle['product_single_page']['save_label'] ) ), merchant_kses_allowed_tags( array( 'bdi' ) ) )
115 : wp_kses(
116 /* Translators: 1. Total discount */
117 sprintf( __( 'You save: %s', 'merchant' ), wc_price( $bundle['total_discount'] ) ),
118 merchant_kses_allowed_tags( array( 'bdi' ) )
119 ); ?>
120 </p>
121 <?php endif; ?>
122 <button type="submit" name="merchant-buy-bundle" value="97" class="button alt wp-element-button merchant-add-bundle-to-cart">
123 <?php echo isset( $bundle['product_single_page']['button_text'] ) ? esc_html( Merchant_Translator::translate( $bundle['product_single_page']['button_text'] ) ) : esc_html__( 'Add to cart', 'merchant' ); ?>
124 </button>
125 <div class="merchant-frequently-bought-together-bundle-error"></div>
126 </div>
127 </form>
128 </div>
129 <?php endforeach; ?>
130 <?php endforeach; ?>
131 </div>
132 </div>
133