PluginProbe
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant / 1.8.3
Product Labels, Quick View, Buy Now, Pre-Orders, Frequently Bought Together & More for WooCommerce – Merchant v1.8.3
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.8.3, at templates/modules/frequently-bought-together/single-product.php

119 lines 7.1 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
14 $settings = isset( $args['settings'] ) ? $args['settings'] : array();
15 ?>
16 <div class="merchant-frequently-bought-together <?php echo isset( $settings['single_product_placement'] ) ? esc_attr( $settings['single_product_placement'] ) : 'after-summary' ?>">
17 <h3 class="merchant-frequently-bought-together-title">
18 <?php echo isset( $settings['title'] ) ? esc_html( Merchant_Translator::translate( $settings['title'] ) ) : esc_html__( 'Frequently Bought Together', 'merchant' ) ?>
19 </h3>
20 <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() ) ?>">
21 <?php foreach($args['bundles'] as $parent_id => $bundles ) : ?>
22 <?php foreach ( $bundles as $key => $bundle ) :
23 $bundle_has_variable_product = false;
24 $discount_type = isset( $bundle['layout'] ) ? $bundle['layout'] : '';
25 $discount_value = isset( $bundle['discount_value'] ) ? $bundle['discount_value'] : 0;
26 $has_no_discount = $discount_value <= 0;
27
28 ?>
29 <?php if ( empty( $bundle['products'] ) ) continue ?>
30 <div class="merchant-frequently-bought-together-bundle<?php echo ( $has_no_discount ) ? ' has-no-discount' : ''; ?>">
31 <form class="merchant-frequently-bought-together-form" data-product="<?php echo esc_attr( $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 ); ?>">
32 <div class="merchant-frequently-bought-together-bundle-products">
33 <?php foreach ( $bundle['products'] as $product_key => $product ) :
34 $is_variable_product = isset( $product['type'] ) && 'variable' === $product['type'] ? true : false;
35
36 if( $is_variable_product ) {
37 $bundle_has_variable_product = true;
38 }
39
40 ?>
41
42 <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'] ); ?>">
43 <?php echo wp_kses_post( $product['image'] ); ?>
44 <div class="merchant-frequently-bought-together-bundle-product-contents">
45 <p class="woocommerce-loop-product__title">
46 <a href="<?php echo esc_url( $product['permalink'] ); ?>" target="_blank">
47 <?php echo esc_html( $product['title'] ); ?>
48 </a>
49 </p>
50 <div class="merchant-frequently-bought-together-bundle-product-price">
51 <?php echo wp_kses( $product['price_html'], merchant_kses_allowed_tags( array( 'bdi' ) ) ); ?>
52 </div>
53 <?php if ( isset( $product['attributes'] ) && ! empty( $product['attributes'] ) ) : ?>
54 <div class="merchant-frequently-bought-together-bundle-product-attributes" data-nonce="<?php echo esc_attr( wp_create_nonce( 'mrc_get_variation_data_nonce' ) ); ?>">
55 <?php foreach ( $product['attributes'] as $key => $attribute ) : ?>
56 <select name="<?php echo esc_attr( $key ) ?>" required>
57 <option value="">
58 <?php echo esc_html(
59 /* Translators: 1. Attribute label */
60 sprintf( __( 'Select %s', 'merchant' ), $attribute['label'] )
61 ); ?>
62 </option>
63 <?php foreach ( $attribute['terms'] as $_term ) : ?>
64 <option value="<?php echo esc_attr( $_term['slug'] ) ?>" <?php selected( $_term['selected'], true, true ); ?>><?php echo esc_html( $_term['name'] ) ?></option>
65 <?php endforeach; ?>
66 </select>
67 <?php endforeach; ?>
68 </div>
69 <?php endif; ?>
70 </div>
71 <?php if ( $product_key !== ( count( $bundle['products'] ) - 1 ) ) : ?>
72 <div class="merchant-frequently-bought-together-bundle-product-plus">+</div>
73 <?php endif; ?>
74 </div>
75 <?php endforeach; ?>
76 </div>
77 <div class="merchant-frequently-bought-together-bundle-offer">
78 <p class="merchant-frequently-bought-together-bundle-total">
79 <?php echo isset( $settings['price_label'] ) ? esc_html( Merchant_Translator::translate( $settings['price_label'] ) ) : esc_html__( 'Bundle price', 'merchant' ); ?>
80 </p>
81 <?php if ( $bundle_has_variable_product ) : ?>
82 <?php if ( $has_no_discount ) : ?>
83 <p class="merchant-frequently-bought-together-bundle-variable-default-message"><?php echo esc_html( Merchant_Translator::translate( $settings['no_variation_selected_text_has_no_discount'] ) ); ?></p>
84 <?php else : ?>
85 <p class="merchant-frequently-bought-together-bundle-variable-default-message"><?php echo esc_html( Merchant_Translator::translate( $settings['no_variation_selected_text'] ) ); ?></p>
86 <?php endif; ?>
87 <?php endif; ?>
88
89 <p class="merchant-frequently-bought-together-bundle-total-price price<?php echo $bundle_has_variable_product ? ' merchant-hidden' : ''; ?>">
90 <?php if ( $has_no_discount ) : ?>
91 <ins class="mrc-fbt-total-price"><?php echo wp_kses( wc_price( $bundle['total_price'] ), merchant_kses_allowed_tags( array( 'bdi' ) ) ); ?></ins>
92 <?php else : ?>
93 <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>
94 <ins class="mrc-fbt-total-discounted-price"><?php echo wp_kses( wc_price( $bundle['total_discounted_price'] ), merchant_kses_allowed_tags( array( 'bdi' ) ) ); ?></ins>
95 <?php endif; ?>
96 </p>
97 <?php if ( ! $has_no_discount ) : ?>
98 <p class="merchant-frequently-bought-together-bundle-save<?php echo $bundle_has_variable_product ? ' merchant-hidden' : ''; ?>">
99 <?php echo isset( $settings['save_label'] )
100 ? wp_kses( str_replace( '{amount}', wc_price( $bundle['total_discount'] ), Merchant_Translator::translate( $settings['save_label'] ) ), merchant_kses_allowed_tags( array( 'bdi' ) ) )
101 : wp_kses(
102 /* Translators: 1. Total discount */
103 sprintf( __( 'You save: %s', 'merchant' ), wc_price( $bundle['total_discount'] ) ),
104 merchant_kses_allowed_tags( array( 'bdi' ) )
105 ); ?>
106 </p>
107 <?php endif; ?>
108 <button type="submit" name="merchant-buy-bundle" value="97" class="button alt wp-element-button merchant-add-bundle-to-cart">
109 <?php echo isset( $settings['button_text'] ) ? esc_html( Merchant_Translator::translate( $settings['button_text'] ) ) : esc_html__( 'Add to cart', 'merchant' ); ?>
110 </button>
111 <div class="merchant-frequently-bought-together-bundle-error"></div>
112 </div>
113 </form>
114 </div>
115 <?php endforeach; ?>
116 <?php endforeach; ?>
117 </div>
118 </div>
119