Woocommerce plugin for minimum order and add-to-card-step

I think YITH Woocommerce Minimum Maximum Quantity plugin is the best solution for your purpose. It enables you to set a minimum or maximum quantity for product selection. It also shows quantity/amount error messages to your customers. Moreover, you can use the plugin to set a different minimum quantity for each of the product. So, … Read more

Call PHP file within a plugin to activate function

Here’s an approach that would be more portable (so you don’t have to call wp-load.php directly, which is something you want to avoid) and also would allow you to revise the URL to not point to the /wp-content/plugins/ directory (also something you want to avoid): add_action( ‘init’, ‘my_pdf_generator’ ); function my_pdf_generator() { // sniff out … Read more

Same log message keeps on printing to debug.log file thousand of times

OK, as far as I understand, you’ve put this code: $debug_log = “DEBUG-debug log”; trigger_error($debug_log); //OR error_log($debug_log); directly in your functionsphp` file. It means, that this code will be executed (so new log item will be added to log file) every time the functions.php file is loaded – so during every request to your WP. … Read more

Show special field when correct shipping is chosen

You need to setup the change event on the field: $(‘select.shipping-field’).on(‘change’, function()) { $.post( ajaxurl, { action: ‘shipping_special’, data: ‘your data here..’ }, function(response){ // The response should contain your special field HTML } ); }); You can pass the current shipping select option Then your theme’s functions.php file needs to have the action to … Read more

Define a wordpress constant through plugin functions?

I don’t think you should define constants in your plugin. It will be very hard to debug later on. IMHO using wp_revisions_to_keep filter will be much nicer solution. So your code could look like this: add_filter( ‘wp_revisions_to_keep’, ‘my_revisions_to_keep_based_on_settings’, 10, 2 ); function my_revisions_to_keep_based_on_settings( $num, $post ) { // change that according to your needs return … Read more

Problem with parameters in url and pagination

Use remove_query_arg() function. DOCUMENTATION and EXAMPLES remove_query_arg( ‘message’ ) ; in pagination code like this. $current_page = max(1, get_query_var(‘paged’)); echo paginate_links(array( ‘base’ => remove_query_arg( ‘message’,get_pagenum_link(1) ) . ‘%_%’, ‘format’ => ‘page/%#%/’, ‘current’ => $current_page, ‘total’ => intval($total_patients / 10) + 1, ‘prev_next’ => true, ‘type’ => ‘list’, ));