Add filter to support Subscriptions, Bundles, Etc.

Issue #985 new
Valentina R created an issue

Requested here:

I’ve created an extension to have recurring appointments, and integrate it with WooCommerce Subscriptions, and while working on it, I found 2 functions:
– WC_Appointments_Admin_Ajax->calculate_costs
– WC_Appointments_Admin_Ajax->get_time_slots_for_date

in both, you have the following code for determining the appointable product id:

$product_id = $posted['add-to-cart'] ?? 0;
if ( ! $product_id && isset( $posted['appointable-product-id'] ) ) {
    $product_id = $posted['appointable-product-id'];
}

Is there a possibility for you to change those lines, so we can pass ‘appointable-product-id’ directly from a form that belongs to another product (E.g. a bundle or subscription enrolment product), so the add-to-cart value gets ignored?
I suggest something like this (or add a filter):

// Find Appointable Product ID
$product_id = $posted['appointable-product-id'] ?? ( $posted['add-to-cart'] ?? 0 );

Right now I need to rewrite the two entire functions and replace the entire ajax actions in order to change just that line.

I’ve checked the logic, and it shouldn’t affect the rescheduling form, that uses ‘appointable-product-id’, but please correct me if I’m missing something.

This will open the door to integrating the appointable product within any other types of products.

Comments (0)

  1. Log in to comment