Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Disable WC product zoom and quantity input
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomo-secchi committed Apr 14, 2023
1 parent 4a8b005 commit 211a47f
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 112 deletions.
2 changes: 1 addition & 1 deletion functionality-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Description: This is an awesome custom plugin with functionality that I'd like to keep when switching things.
* Author: Giacomo Secchi
* Author URI: https://giacomosecchi.com
* Version: 0.0.13
* Version: 0.0.14
*/

/* Place custom code below this line. */
Expand Down
66 changes: 66 additions & 0 deletions includes/class-mcf-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
define( 'MCF_WOOCOMMERCE_QUANTITY_AS_SELECT', false );
}

if ( ! defined( 'MCF_WOOCOMMERCE_DISABLE_SINGLE_PRODUCT_QTY' ) ) {
define( 'MCF_WOOCOMMERCE_DISABLE_SINGLE_PRODUCT_QTY', false );
}

if ( ! defined( 'MCF_WOOCOMMERCE_DISABLE_PRODUCT_ZOOM' ) ) {
define( 'MCF_WOOCOMMERCE_DISABLE_PRODUCT_ZOOM', false );
}
class MCF_WooCommerce {

/**
Expand All @@ -37,6 +44,14 @@ public function __construct() {
}


if ( MCF_WOOCOMMERCE_DISABLE_SINGLE_PRODUCT_QTY ) {
$this->disable_quantity_input();
}

if ( MCF_WOOCOMMERCE_DISABLE_PRODUCT_ZOOM ) {
$this->disable_product_zoom();
}

if ( ! MCF_WOOCOMMERCE_REDIRECT_CHECKOUT ) {
return false;
}
Expand Down Expand Up @@ -119,4 +134,55 @@ public function woocommerce_loop_add_to_cart_link( $add_to_cart_html ) {
public function remove_add_to_cart_message( $message ){
return '';
}


// Disable quantity selector for product and product variation
public function disable_quantity_input() {
add_filter( 'woocommerce_quantity_input_args', function ( $args, $product ) {
$args['max_value'] = 1;

return $args;
}, 10, 2 );

add_filter( 'woocommerce_available_variation', function ( $data, $product, $variation ) {
$data['max_qty'] = 1;

return $data;
}, 10, 3);
}

// Disable zoom
public function disable_product_zoom() {
add_action( 'wp', function () {
remove_theme_support( 'wc-product-gallery-zoom' );
// remove_theme_support( 'wc-product-gallery-lightbox' );
// remove_theme_support( 'wc-product-gallery-slider' );
} , 100 );

add_filter( 'woocommerce_single_product_image_thumbnail_html', function ( $html ) {
return strip_tags( $html, '<div><img>' );
} );
}

public function woocommerce_custom_tabs () {
add_filter( 'woocommerce_product_tabs', function( $tabs ) {

// Remove additional information tab on Product Page
unset( $tabs['reviews'] );
unset( $tabs['additional_information'] );


// Insert additional information into description tab on Product Page
$tabs['description']['callback'] = function() {
global $product;
wc_get_template( 'single-product/tabs/description.php' );

if ( $product && ( $product->has_attributes() || apply_filters( 'wc_product_enable_dimensions_display', $product->has_weight() || $product->has_dimensions() ) ) ) {
wc_get_template( 'single-product/tabs/additional-information.php' );
}
};

return $tabs;
}, 20 );
}
}
111 changes: 0 additions & 111 deletions mu-plugins/custom_functions.php

This file was deleted.

66 changes: 66 additions & 0 deletions mu-plugins/project-custom-functions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php
/**
* Plugin Name: Project engine room
* Author: Giacomo Secchi
* Author URI: https://giacomosecchi.com
* Version: 1.0.0
*/

/* Place custom code below this line. */


// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}



// custom code for the current project


define( 'GTM4WP_HARDCODED_GTM_ID', '' );
define( 'GTM4WP_HARDCODED_GTM_ENV_AUTH', '' );
define( 'GTM4WP_HARDCODED_GTM_ENV_PREVIEW', '' );

define( 'MCF_WOOCOMMERCE_REDIRECT_CHECKOUT', true );
define( 'MCF_WOOCOMMERCE_DISABLE_SINGLE_PRODUCT_QTY', true );
define( 'MCF_WOOCOMMERCE_DISABLE_PRODUCT_ZOOM', true );


// add elements to disable
add_filter( 'mcf_disable_features', function () {
$args[] = 'woocommerce_sale_flash';
// $args[] = 'woocommerce_twenty_twenty_two_styles';

return $args;
}, 10, 1 );


// Add parameters to url
add_filter( 'mcf_query_vars', function ( $qv ) {

return array ( 'show-wheel', 'test-1');
} );






















0 comments on commit 211a47f

Please sign in to comment.