• i wonder if anyone out there knows of a solution for the following:

    i need an appointments plugin (of which there are many obviously), but i need something whereas i can set credits for registered users which can be redeemed against bookings, rather than having a paypal or gateway system for payments..

    I’ve been using appointment booking pro in joomla (which does everything i need), but need a wordpress solution as we’re migrating the site..

    any ideas?

Viewing 11 replies - 1 through 11 (of 11 total)
  • matt, i’m looking for exactly the same thing – you found a solution, by any chance?

    Did you find a solution to this?

    I am desperately trying to find a similar solution, but have found absolutely nothing so far.

    Thread Starter matt bates

    (@mattbates)

    no, sorry guys i haven’t..

    i’m still pouring through the many available plug-in hoping to find something close to what i need.

    if enough people want this, perhaps we could commission a developer to make this or modify an existing plug for us?

    would welcome any ideas…

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    if enough people want this, perhaps we could commission a developer to make this or modify an existing plug for us?

    If you do decide to go that route please post to https://jobs.wordpress.net/ and not here.

    Offers to pay get closed when found which you’ve not done but tread carefully. ??

    https://codex.www.ads-software.com/Forum_Welcome#Offering_to_Pay

    I found the following plugin: https://www.ads-software.com/plugins/types/

    What I did was create a new user meta field called “credits” and started from there.

    <div id="headertext-main">
    
        <?php
    	/**
    	 * steve's sauce
    	 */
    
    		if ( is_user_logged_in() ) {
    		global $current_user;
    		get_currentuserinfo();
    		$customer_credits = types_render_usermeta_field("credits", array("user_current" => "true", FIELD_VALUE));
    
    		echo 'Welcome ' . "<a href='?page_id=43'> $current_user->display_name </a>";
    		echo "<a href='?product=tutoring-credit-1h'>($customer_credits) </a>";
    		echo "<a href='?page_id=48'>logout</a>";
    
    		} else {
    		  echo 'Welcome visitor! ';
    		  echo "<a href='?page_id=43'>Click or touch to login/register.</a>";
    		}
    
    	/**
    	 * steve's sauce
    	 */
    
    	?>
        </div>

    I know my code sucks, but as it stands, it’s working. But this pretty much displays in my header the number of credits the user has. I am currently working on code to put behind Woocommerce orders and then finally for the calendar booking system that I’ll use and I’m more than willing to come back to this thread to share my future code with any of you guys who might find it useful.

    I haven’t done any coding since leaving Uni 6-7 years ago, so I have no idea how I’d even create an addon out of all of this, but I am sure there are some very smart people here that can give us a few pointers that would allow us to create a basic implementation.

    I thought I’d come back and quickly explain what the code I pasted does.

    In my header.php, I put this code so that at the top of every page, a check is made to see if the user is logged in or not. If not, they are directed to the woocommerce register/login page. If they are logged in, it shows their display name plus the number of credits that they have per the API from the WordPress Types plugin.

    Thread Starter matt bates

    (@mattbates)

    Offers to pay get closed when found which you’ve not done but tread carefully. ??

    yes, no worries! i’ll make sure i go down the appropriate route..

    @stevenwilliams i’d be very interested to hear how you get on integrating that with a calendar booking system, please do keep us posted ??

    This is the second component of my credits system, this is the part that when a payment is completed, the credits are added to the usermeta > wpcf-credits field. I’ll repeat just for conciceness that I got this extra field by using the plugin called ‘types’

    function credits_add_quantity($order_id) {
    	global $wpdb, $woocommerce;
    	$order = new WC_Order( $order_id );
    	$user_id = (int)$order->user_id;
    	if ( count( $order->get_items() ) > 0 ) {
    	foreach( $order->get_items() as $item ) {
    
    		$quantity=$item['qty'];
    
    	}
    	}
    		$quan = intval($quantity);
    		$customer_credits = $wpdb->get_var("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = '$user_id' AND meta_key = 'wpcf-credits'" );
    		$newcredits = $quan + $customer_credits;
    		$wpdb->update('wp_usermeta', array('meta_value' => $newcredits), array('meta_key' => 'wpcf-credits', 'user_id' => $user_id), array( '%d' ), array( '%s' ));
    }
    add_action('woocommerce_order_status_completed', 'credits_add_quantity');

    I put this code into my wordpress-functions.php file at the very bottom.

    If anyone can suggest improvements to my code, by all means let me know.

    I will choose a booking system today and try to implement the credits system into that.

    made a mistake in my previous post. I put the code into woocommerce-functions.php

    Jesse

    (@ocalawebdesigner)

    Hey guys, have you been able to get a successful combination working? Like yourselves, I am needing a similar structure.

    User signs up.
    User buys credit package.
    User uses credits for bookings.

    Hey all …

    This was the last part of my code needed to get a booking system working.

    I used the plugin appointment calendar https://www.ads-software.com/plugins/appointment-calendar/

    I decided to go with the apcal_mobile version of it for now, so I edited the appointment-calendar-mobile.php file within the plugin directory and around line 92, I entered the following code:

    global $current_user;
    			get_currentuserinfo();
    			$customer_credits = $wpdb->get_var("SELECT meta_value FROM $wpdb->usermeta WHERE user_id = '$current_user->ID' AND meta_key = 'wpcf-credits'" );
    			$new_creds = $customer_credits - 1;
    			$wpdb->update('wp_usermeta', array('meta_value' => $new_creds), array('meta_key' => 'wpcf-credits', 'user_id' => $current_user->ID), array( '%d' ), array( '%s' ));
    			error_log( "user id is $current_user->ID", 0 );

    I’ve obviously had to secure certain pages, which is all down to how you want to setup your pages, but when I have finished the site, I will link it here to let you see it working.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘appointment booking plugin with a credit system’ is closed to new replies.