// Add WooCommerce mini-cart to the main nav (primary_navigation)
add_filter('wp_nav_menu_items', [$this, 'woocommerce_cart_menu'], 10, 2);
+ // Update mini-cart link count on AJAX updates
+ add_filter('woocommerce_add_to_cart_fragments', [$this, 'woocommerce_add_to_cart_fragment']);
+
+ // Remove content wrappers
+ remove_action('woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10);
+ remove_action('woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10);
+
// Remove product sorting dropdowns
// Ref: https://rudrastyh.com/woocommerce/remove-product-sorting-dropdown.html
remove_action('woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30);
// Remove product count
remove_action('woocommerce_before_shop_loop', 'woocommerce_result_count', 20);
+ // Replace add to cart button with icon
+ //add_filter('woocommerce_loop_add_to_cart_link', [$this, 'add_to_cart_button'], 10, 3);
+
+ // Change number of columns on shop page
+ add_filter('loop_shop_columns', function() { return 3; }, 999);
+
+ // Replace remove cart item "x" with custom icon
+ add_filter('woocommerce_cart_item_remove_link', [$this, 'cart_remove_link'], 10, 2);
+
// Remove product single page meta (Category)
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40);
// Also disable the headings in custom tabs
add_filter('yikes_woocommerce_custom_repeatable_product_tabs_heading', '__return_false');
+
+ // Add Newsletter subscription checkbox to checkout
+ add_action('woocommerce_review_order_before_submit', [$this, 'newsletter_checkbox']);
+ // Save Newsletter checkbox
+ add_action('woocommerce_checkout_update_order_meta', [$this, 'newsletter_checkbox_process']);
}
public function woocommerce_cart_menu($menu, $args) {
+ // The shop is only available on the French version of the site so we need to check this
+ $isFrench = apply_filters('wpml_current_language', NULL) === 'fr';
+
// Only continue if woocommerce mini cart is available and we're on the primary_navigation menu
if (!function_exists('woocommerce_mini_cart')
//|| WC()->cart->cart_contents_count < 1
+ || !$isFrench
|| $args->theme_location !== 'primary_navigation') {
return $menu;
}
return $menu;
}
+ public function woocommerce_add_to_cart_fragment($fragments) {
+ // Re-run and populate updated cart link template
+ $fragments['a.menu-cart-link'] = template('woocommerce/mini-cart-link');
+
+ return $fragments;
+ }
+
+ public function add_to_cart_button($html, $product, $args) {
+ if ($product->is_purchasable() && !$product->is_sold_individually() && $product->is_in_stock() && 'variable' != $product->get_type() && 'bundle' != $product->get_type()) {
+
+ return sprintf(
+ '<a href="%s" data-quantity="%s" class="%s" %s>%s</a>',
+ esc_url( $product->add_to_cart_url() ),
+ esc_attr( isset( $args['quantity'] ) ? $args['quantity'] : 1 ),
+ //esc_attr( isset( $args['class'] ) ? $args['class'] : 'button' ),
+ 'add_to_cart_button ajax_add_to_cart', // WooCommerce CSS is a mess so just add these for the JS to hook
+ isset( $args['attributes'] ) ? wc_implode_html_attributes( $args['attributes'] ) : '',
+ \BladeSvgSage\svg_image('icons/cart-add')->toHtml()
+ );
+
+ //return '<button>'. \BladeSvgSage\svg_image('icons/cart')->toHtml() .'</button><pre>'. print_r($args, true) .'</pre>';
+ }
+
+ return $html;
+ }
+
+
+ public function cart_remove_link($html, $cart_item_key) {
+
+ // Instead of trying to recreate the full HTML link with all the attributes, it's easier
+ // to replace the part we don't want: the × with the SVG icon
+ $icon = \BladeSvgSage\svg_image('icons/poubelle')->toHtml();
+
+ return str_replace('×', $icon, $html);
+
+ }
+
+ public function newsletter_checkbox() {
+ woocommerce_form_field('newsletter_subscribe', array(
+ 'type' => 'checkbox',
+ 'class' => [],
+ 'label' => __('Je souhaite recevoir la newsletter et les offres de PhysioAssist'),
+ 'required' => false,
+ 'default' => 1, // Pre-check the checkbox
+ ), WC()->checkout->get_value('newsletter_subscribe'));
+ }
+
+ public function newsletter_checkbox_process($order_ID) {
+
+ $newsletter = (isset($_POST['newsletter_subscribe']) && $_POST['newsletter_subscribe'] == 1) ? __('Oui') : __('Non');
+
+ update_post_meta($order_ID, 'Newsletter', $newsletter);
+
+ // ToDo: send an e-mail notifying when there is a new subscriber
+ if ($newsletter === __('Oui')) {
+ // ADDRESS: $_POST['billing_email']
+ }
+
+ }
+
}
]
},
"publicPath": "/wp-content/themes/physioassist",
- "devUrl": "https://physioassist.test",
+ "devUrl": "https://fr.physioassist.test",
"proxyUrl": "https://localhost:3000",
"cacheBusting": "[name]_[hash:8]",
"watch": [
--- /dev/null
+<?xml version="1.0" ?><svg viewBox="0 0 1792 1792" xmlns="http://www.w3.org/2000/svg"><path d="M1280 704q0-26-19-45t-45-19h-128v-128q0-26-19-45t-45-19-45 19-19 45v128h-128q-26 0-45 19t-19 45 19 45 45 19h128v128q0 26 19 45t45 19 45-19 19-45v-128h128q26 0 45-19t19-45zm-576 832q0 53-37.5 90.5t-90.5 37.5-90.5-37.5-37.5-90.5 37.5-90.5 90.5-37.5 90.5 37.5 37.5 90.5zm896 0q0 53-37.5 90.5t-90.5 37.5-90.5-37.5-37.5-90.5 37.5-90.5 90.5-37.5 90.5 37.5 37.5 90.5zm128-1088v512q0 24-16 42.5t-41 21.5l-1044 122q1 7 4.5 21.5t6 26.5 2.5 22q0 16-24 64h920q26 0 45 19t19 45-19 45-45 19h-1024q-26 0-45-19t-19-45q0-14 11-39.5t29.5-59.5 20.5-38l-177-823h-204q-26 0-45-19t-19-45 19-45 45-19h256q16 0 28.5 6.5t20 15.5 13 24.5 7.5 26.5 5.5 29.5 4.5 25.5h1201q26 0 45 19t19 45z"/></svg>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<svg version="1.1"
+ xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 140 140"
+ xml:space="preserve">
+ <path d="M114.8,43.8H36c-2.4,0-4.4,2-4.4,4.4v78.8c0,7.2,5.9,13.1,13.1,13.1H106c7.2,0,13.1-5.9,13.1-13.1V48.1
+ C119.2,45.7,117.2,43.8,114.8,43.8z M110.4,126.9c0,2.4-2,4.4-4.4,4.4H44.8c-2.4,0-4.4-2-4.4-4.4V52.5h70V126.9z"/>
+ <path d="M62.3,113.8c2.4,0,4.4-2,4.4-4.4v-35c0-2.4-2-4.4-4.4-4.4s-4.4,2-4.4,4.4v35C57.9,111.8,59.9,113.8,62.3,113.8
+ z"/>
+ <path d="M88.5,113.8c2.4,0,4.4-2,4.4-4.4v-35c0-2.4-2-4.4-4.4-4.4s-4.4,2-4.4,4.4v35C84.2,111.8,86.1,113.8,88.5,113.8
+ z"/>
+ <path d="M129.7,11.7c-0.5-2.4-2.8-3.9-5.2-3.4l-29.9,6.4l-0.9-4.3C92.1,3.3,85.2-1.2,78.1,0.3L52.4,5.7
+ c-7.1,1.5-11.6,8.5-10.1,15.6l0.9,4.2l-30,6.4c-2.4,0.5-3.9,2.8-3.4,5.2c0.4,2.1,2.3,3.5,4.3,3.5c0.3,0,0.6,0,0.9-0.1l34.2-7.3
+ c0,0,0,0,0.1,0l42.8-9.1c0,0,0,0,0,0l34.2-7.3C128.7,16.4,130.2,14,129.7,11.7z M50.8,19.5c-0.5-2.4,1-4.7,3.4-5.2l25.7-5.5
+ c0.3-0.1,0.6-0.1,0.9-0.1c2,0,3.8,1.4,4.3,3.5l0.9,4.3l-34.2,7.3L50.8,19.5z"/>
+</svg>
margin-bottom: 0.8em;
margin-top: 0.9em;
+ #mobileMenu &
+ width: 26px
+ margin-left: auto
+ margin-right: auto
+
// Create a larger hover zone for the cart icon to make
// it easier to touch and keep over when viewing the dropdown
&:before
bottom: @top
left: @top
+ &-count
+ position: absolute
+ top: -0.25em
+ left: -0.65em
+ width: 1.5em
+ color: #fff
+ font-size: 12px
+ line-height: 1.5
+ text-align: center
+ border-radius: 50%
+ overflow: hidden
+ background-color: $colors.blue
.sub-menu-mini-cart
padding: 0
left: -0.8em
top: 0
color: $colors.red !important
- width: 1.5rem
+ width: 1em
height: @width
line-height: 1
- font-size: @width
+ font-size: 1.7rem
text-align: center
+ svg
+ fill: currentColor
+ width: 0.7em
+ height: @width
+
&:hover
color: #fff !important
background: $colors.red
box-shadow: 0 0 0 2px $colors.dark-blue
#respond input#submit,
- a.button,
+ a.button,
+ a.added_to_cart,
button.button,
input.button
font-smoothing()
color: #fff
font-size: 14px
font-weight: 700
+ line-height: 1
text-align: center
text-transform: uppercase
transition: background-color 0.15s
&:disabled[disabled]:hover
background-color: #888
- a.added_to_cart
- padding-top: 0
- margin: 1em
+ .add_to_cart_button
+ position: relative
color: $colors.dark-blue
&:hover
color: $colors.blue
- .single_add_to_cart_button
- margin-left: 1.5em !important
+ &.loading
+ opacity: 0.7
+ cursor: wait
+ pointer-events: none
+
+ // Tick after successfully adding product
+ &.added:after
+ content: '\e017'
+ font-family: 'WooCommerce'
+ display: inline-block
+ position: absolute
+ top: 0
+ right: -2.4em
+ font-size: 1.2em
+ color: #77a464
+
+ svg
+ fill: currentColor
+ margin-left: 1em
+ width: 35px
+
+ + a.added_to_cart
+ margin-top: 1em
+
+ a.added_to_cart
+ display: block
+ width: max-content
+
+ // Remove from cart link
+ a.remove
+ display: flex
+ align-items: center
+ justify-content: center
+ color: $colors.red !important
+ font-size: 1.7rem
+ width: 1em
+ height: @width
+
+ &:hover
+ background-color: $colors.red !important
+
+ svg
+ fill: currentColor
+ width: 0.7em
+ height: @width
// Product grid
ul.products
li.product
+
+ +below(550px)
+ width: 100% !important
+
.woocommerce-loop-category__title,
.woocommerce-loop-product__title,
h3
p.price, span.price
margin-bottom: 0.5em
+ div.summary
+ width: 64%
+ +below(769px)
+ width: 100%
+
div.images
+ width: 33%
+ +below(769px)
+ width: 100%
+
.woocommerce-product-gallery__wrapper
line-height: 1 // So spacing between inline-block images is correct
.elementor-section.elementor-section-boxed > .elementor-container
padding: 0
+ #tab-additional_information
+ h2
+ display: none
+
// Cart
&-cart
table.cart
//=============
// Quantity input -/+ buttons
+.qib-container
+ margin-right: 1.5em
+ margin-bottom: 0.75em
+
.qib-button
position: relative
text-align: center
<div class="content-inner vertical-spacing">
@php
- do_action('get_header', 'shop');
+ //do_action('get_header', 'shop');
do_action('woocommerce_before_main_content');
@endphp
@php
do_action('woocommerce_after_main_content');
- do_action('get_sidebar', 'shop');
- do_action('get_footer', 'shop');
+ //do_action('get_sidebar', 'shop');
+ //do_action('get_footer', 'shop');
@endphp
</div>
--- /dev/null
+<a class="menu-cart-link" href="{{ wc_get_cart_url() }}">
+ @svg('icons/cart', 'menu-cart-icon')
+ @if (($cart_count = WC()->cart->get_cart_contents_count()) > 0)
+ <span class="menu-cart-count">{{ $cart_count }}</span>
+ @endif
+</a>
<li class="menu-cart menu-item">
- <a class="menu-cart-link" href="{{ wc_get_cart_url() }}">
- @svg('icons/cart', 'menu-cart-icon')
- </a>
+ @include('woocommerce.mini-cart-link')
<ul class="sub-menu sub-menu-mini-cart">
<li>
<div class="content-inner vertical-spacing">
@php
- do_action('get_header', 'shop');
+ //do_action('get_header', 'shop');
do_action('woocommerce_before_main_content');
@endphp
@php
do_action('woocommerce_after_main_content');
- do_action('get_sidebar', 'shop');
- do_action('get_footer', 'shop');
+ //do_action('get_sidebar', 'shop');
+ //do_action('get_footer', 'shop');
@endphp
</div>