Crocoblock / suggestions

The suggestions for CrocoBlock project
196 stars 79 forks source link

Appointments - Easy additions to the macro list #6577

Open tomandersen opened 1 year ago

tomandersen commented 1 year ago

Before adding a new feature request, please, make sure you’ve checked:

Appointments is a private repo.

I could write the easy part of this feature request in 5 mins by editing the file

jet-appointments-booking/includes/macros.php

REQUEST

Please add support for all fields in the appointment table: EG Missing: user_name

This would require adding a few lines of code and a new function called appointment_user_name

BUT I have added a column to the Appointments table! So how to make macros for all columns in the ? You have a thing called "Appointment Meta" perhaps one called "Appointment Field" would be nice.

That way we can get the user_name and user_phone into the admin emails we send out! Thanks.

Screen Shot 2023-02-28 at 3 35 40 PM

Screen Shot 2023-02-28 at 3 36 50 PM
morosmo commented 1 year ago

+10

tomandersen commented 1 year ago

"Appointment Field" is the only addition needed in the code (ie add Appointment Field to the menu) . I can see how to code it, but don't want a custom version of the plugin running!

ihslimn commented 1 year ago

You may use a custom code to add something you need without modifying the plugin itself

Something like this should work

class Jet_Appointment_Additional_Macros {

    private $manager;

    public function __construct() {
        add_filter( 'jet-apb/macros-list', array( $this, 'add_macros' ), 0, 2 );
    }

    public function add_macros( $macros_list, $manager ) {

        $this->manager = $manager;

        $macros_list['new_macro'] = array(
            'label' => 'New Macro',
            'cb'    => array( $this, 'process_new_macro' ),
            'args'  => array(
                'arg1' => array(
                    'label'   => 'Argument 1',
                    'type'    => 'text',
                    'default' => '',
                ),
            ),
        );

        return $macros_list;

    }

    public function process_new_macro( $result = null, $args_str = null ) {
        $appointment = $this->manager->get_macros_object();
        return $args_str ?? 'test';
    }

}

new Jet_Appointment_Additional_Macros;
heisenberg0924 commented 1 year ago

+1