Today, we’re documenting the process of setting up a WooCommerce store with batch payment processing to reduce transaction fees. We’ll start with the initial setup and test environment.

Project Goals

  • Implement batch payment processing for WooCommerce orders
  • Reduce transaction fees by grouping smaller purchases
  • Keep subscription payments separate from batch processing
  • Process batches on a weekly schedule

Initial Setup

First, we created test products using WP-CLI to simulate a store with small-value items:

bashCopy# Create test products
wp post create --post_type=product --post_title="Small Item $5" --post_status=publish --porcelain
wp post create --post_type=product --post_title="Mini Item $3" --post_status=publish --porcelain
wp post create --post_type=product --post_title="Tiny Item $2" --post_status=publish --porcelain
wp post create --post_type=product --post_title="Micro Item $1" --post_status=publish --porcelain
wp post create --post_type=product --post_title="Nano Item $4" --post_status=publish --porcelain

This created five products with IDs 319-323.

Setting Product Prices

We then set prices using the WP-CLI with the admin user (required for permissions):

bashCopywp wc product update 319 --regular_price=5.00 --user=1
wp wc product update 320 --regular_price=3.00 --user=1
wp wc product update 321 --regular_price=2.00 --user=1
wp wc product update 322 --regular_price=1.00 --user=1
wp wc product update 323 --regular_price=4.00 --user=1

Code Implementation (So Far)

We’ve organized our code into a modular structure with separate files for different functionalities:

phpCopy// includes/batch-payments.php

// Register our custom order status
function register_batch_pending_order_status() {
    register_post_status('wc-batch-pending', array(
        'label'                     => 'Batch Pending',
        'public'                    => true,
        'show_in_admin_status_list' => true,
        'show_in_admin_all_list'    => true,
        'exclude_from_search'       => false,
        'label_count'               => _n_noop('Batch Pending <span class="count">(%s)</span>',
            'Batch Pending <span class="count">(%s)</span>')
    ));
}
add_action('init', 'register_batch_pending_order_status');

Next Steps

  1. Set up Stripe test environment
  2. Create test orders
  3. Implement batch processing logic
  4. Test the complete payment flow
  5. Add admin interface for manual batch processing
  6. Set up automated weekly processing

Stay tuned for Part 2 where we’ll dive into implementing the Stripe integration and batch processing logic.