PluginProbe
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce / 3.3.0
CartFlows – Funnel Builder & Checkout Plugin for WooCommerce v3.3.0
3.3.0 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.1 trunk 1.0.4 1.1.0 1.1.0.1 1.1.1 1.1.10 1.1.11 1.1.12 1.1.13 1.1.14 1.1.15 1.1.16 1.1.17 1.1.18 1.1.19 1.1.2 All 162 releases
cartflows / modules / frequently-bought-together / templates / frontend-widget-row.php

frontend-widget-row.php in CartFlows – Funnel Builder & Checkout Plugin for WooCommerce 3.3.0, at modules/frequently-bought-together/templates/frontend-widget-row.php

77 lines 4.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Frequently Bought Together — single widget row (main, simple, or variable).
4 *
5 * Included per row by frontend-widget.php. Variable rows wrap the label and the
6 * variation select in a row-group so the pair collapses and separates as one unit.
7 *
8 * @package cartflows
9 * @var array{id: int, name: string, image: string, available: bool, is_main: bool, is_extra: bool, show_qty: bool, qty: int, price: float, price_html: string, from_label: string, requires_options: bool, permalink: string, variations: array<int, array{id: int, price: float, label: string}>} $fbt_row Row display data from Cartflows_Fbt_Frontend::get_row_data().
10 */
11
12 if ( ! defined( 'ABSPATH' ) ) {
13 exit;
14 }
15
16 $fbt_is_variable = ! empty( $fbt_row['variations'] );
17 $fbt_needs_page = ! empty( $fbt_row['requires_options'] ) && '' !== $fbt_row['permalink'];
18
19 $fbt_row_class = 'wcf-fbt-widget-row';
20 if ( $fbt_row['is_main'] ) {
21 $fbt_row_class .= ' is-main';
22 }
23 if ( ! $fbt_row['available'] ) {
24 $fbt_row_class .= ' is-unavailable';
25 }
26 if ( $fbt_needs_page ) {
27 $fbt_row_class .= ' requires-options';
28 }
29 if ( $fbt_row['is_extra'] && ! $fbt_is_variable ) {
30 $fbt_row_class .= ' is-extra';
31 }
32 ?>
33 <?php if ( $fbt_is_variable ) : ?>
34 <div class="wcf-fbt-widget-row-group<?php echo $fbt_row['is_extra'] ? ' is-extra' : ''; ?>">
35 <?php endif; ?>
36 <label class="<?php echo esc_attr( $fbt_row_class ); ?>">
37 <?php if ( $fbt_needs_page ) : ?>
38 <span class="wcf-fbt-widget-box-spacer" aria-hidden="true"></span>
39 <?php elseif ( $fbt_row['is_main'] ) : ?>
40 <input type="checkbox" checked disabled data-price="<?php echo esc_attr( (string) $fbt_row['price'] ); ?>" />
41 <?php else : ?>
42 <input type="checkbox" class="wcf-fbt-widget-input" value="<?php echo esc_attr( (string) $fbt_row['id'] ); ?>" data-price="<?php echo esc_attr( (string) $fbt_row['price'] ); ?>" <?php disabled( ! $fbt_row['available'] ); ?> />
43 <?php endif; ?>
44 <span class="wcf-fbt-widget-thumb"><img src="<?php echo esc_url( $fbt_row['image'] ); ?>" alt="<?php echo esc_attr( $fbt_row['name'] ); ?>" loading="lazy" /></span>
45 <span class="wcf-fbt-widget-name"><?php echo esc_html( $fbt_row['name'] ); ?>
46 <?php
47 if ( $fbt_row['is_main'] ) :
48 ?>
49 <em>(<?php esc_html_e( 'this item', 'cartflows' ); ?>)</em><?php endif; ?></span>
50 <?php if ( ! $fbt_row['available'] ) : ?>
51 <span class="wcf-fbt-widget-stock-badge"><?php esc_html_e( 'Out of stock', 'cartflows' ); ?></span>
52 <?php endif; ?>
53 <?php if ( $fbt_row['show_qty'] && ! $fbt_row['is_main'] && ! $fbt_needs_page ) : ?>
54 <input type="number" min="1" step="1" class="wcf-fbt-widget-qty" value="<?php echo esc_attr( (string) $fbt_row['qty'] ); ?>" aria-label="<?php esc_attr_e( 'Quantity', 'cartflows' ); ?>" <?php disabled( ! $fbt_row['available'] ); ?> />
55 <?php endif; ?>
56 <?php if ( $fbt_is_variable ) : ?>
57 <span class="wcf-fbt-widget-price is-from" data-from="<?php echo esc_attr( $fbt_row['from_label'] ); ?>"><?php echo esc_html( $fbt_row['from_label'] ); ?></span>
58 <?php else : ?>
59 <span class="wcf-fbt-widget-price"><?php echo wp_kses_post( $fbt_row['price_html'] ); ?></span>
60 <?php endif; ?>
61 <?php if ( $fbt_needs_page ) : ?>
62 <a class="wcf-fbt-widget-options-link" href="<?php echo esc_url( $fbt_row['permalink'] ); ?>"><?php esc_html_e( 'Select options', 'cartflows' ); ?></a>
63 <?php endif; ?>
64 </label>
65 <?php if ( $fbt_is_variable ) : ?>
66 <div class="wcf-fbt-widget-variation">
67 <select class="wcf-fbt-widget-variation-select" aria-label="<?php esc_attr_e( 'Product variation', 'cartflows' ); ?>">
68 <option value=""><?php esc_html_e( 'Choose an option…', 'cartflows' ); ?></option>
69 <?php foreach ( $fbt_row['variations'] as $fbt_choice ) : ?>
70 <option value="<?php echo esc_attr( (string) $fbt_choice['id'] ); ?>" data-price="<?php echo esc_attr( (string) $fbt_choice['price'] ); ?>"><?php echo esc_html( $fbt_choice['label'] ); ?></option>
71 <?php endforeach; ?>
72 </select>
73 <div class="wcf-fbt-widget-variation-hint"><?php esc_html_e( 'Select a variation to continue', 'cartflows' ); ?></div>
74 </div>
75 </div>
76 <?php endif; ?>
77