Skip to content

Instantly share code, notes, and snippets.

@codersaiful
Last active October 4, 2023 04:47
Show Gist options
  • Save codersaiful/bb7888558949a1a0863ea313117a14d5 to your computer and use it in GitHub Desktop.
Save codersaiful/bb7888558949a1a0863ea313117a14d5 to your computer and use it in GitHub Desktop.
<?php
//COPY THIS BELLOW LINE ONLY TO PASTE IN YOUR functions.php
add_filter('wcmmq_default_qty_option', '__return_true');
add_filter('wcmmq_single_product_min_max_condition', 'wcmmq_custom_default_value_enable', 10, 2);
function wcmmq_custom_default_value_enable($args, $product){
if(!defined('WC_MMQ_PREFIX')) return $args;
$product_id = $product->get_id();
$key = WC_MMQ_PREFIX . 'default_quantity';
$default_value = get_post_meta($product_id, $key, true);
if(empty($default_value)){
$options = \WC_MMQ::getOptions();
$default_value = $options[$key];
}
if(!empty($default_value) && ! is_cart() ){
$args['input_value'] = $default_value;
}
return $args;
}
/**
for security perpose, we have disable default value option in our plugin. Actually it’s conflicting with all type side cart plugin. That’s why we have disable it from our plugin. But if you still want ‘default value’ option,
use following code inside your theme’s functions.php file.
we recommend child theme obviously.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment