Halio and Affiliates Pro


Installed Plugins
* Affiliates Pro
* Affiliates WooCommerce Integration
* Itthinx Updates
* WooCommerce
* WooCommerce Checkout Manager
* WooCommerce Product Vendors
* Halio https://codecanyon.net/item/halio-woocommerce-taxi-booking-plugin/15490036

Hello.

Now we’re managing a web service of taxi booking with Halio plugin.
The reason why we adopt Affiliates Pro is that we have plan to offer affiliate program.
For example, if the rate is set to 5 percent(Rate value: 0.5), and the taxi fare of order is 100 USD,
the commission fee of registered affiliate member is 5 USD.

Because of the specification of Halio, we register only one Products data of WooCommerce and its price is 0 USD.

In this time, we have problem.
When the user comes from affiliate link generated by Affiliates Pro, and this user makes order, taxi fare of order can’t reflect to amount or reference_amount column in data of wp_aff_referrals table.
We guess that the cause of problem is price(0 USD) of Products data of WooCommerce.
But even if we change price of Products data, it’s meaningless.

In this problem, can we solve if we change setting of Affiliates Pro or WooCommerce or other plugins?
Or if we need to modify PHP code of Affiliate Pro, which code do we modify?

This question might be difficult, but we’d like to know the solution or some tips.

Regards.

Posted in

Comments

7 responses to “Halio and Affiliates Pro”

  1. George Avatar

    Hi Makoto,

    Please send me temp admin access to your live or staging site to george@itthinx.com. I would like to have a closer look and give you more detailed instructions on how to proceed. I think it’ll be better that way since Halio is a premium plugin.

    Kind regards,
    George

  2. Makoto Avatar

    After my last post, I’ve seen php sources of Halio.
    In Halio, when the wp_posts data creates, the function is defines below:


    function halio_create_wc_product() {
    $existing_id = halio_get_settings_row(‘wc_product_id’)->value;

    if ( !empty($existing_id) ) {
    return $existing_id;
    }

    $user_id = get_current_user_id() ? get_current_user_id() : 1;

    $new_product = array(
    ‘post_author’ => $user_id,
    ‘post_title’ => ‘Taxi Fare’,
    ‘post_status’ => ‘publish’,
    ‘post_type’ => ‘product’
    );

    $post_id = wp_insert_post($new_product);
    update_post_meta($post_id, ‘_stock_status’, ‘instock’);
    update_post_meta($post_id, ‘_visibility’, ‘hidden’);
    update_post_meta($post_id, ‘_stock’, ”);
    update_post_meta($post_id, ‘_virtual’, ‘yes’);
    update_post_meta($post_id, ‘_regular_price’, ‘0’);
    update_post_meta($post_id, ‘_featured’, ‘no’);
    update_post_meta($post_id, ‘_manage_stock’, ‘no’);
    update_post_meta($post_id, ‘_sold_individually’, ‘yes’);
    update_post_meta($post_id, ‘_price’, ‘0’);
    return $post_id;
    }

    Other php sources don’t have meta_key string “price” when data registration.
    Halio has $_POST key “halio_price” and this is taxi fare.

    So I modified upper funtion like below:

    function halio_create_wc_product() {
    $existing_id = halio_get_settings_row(‘wc_product_id’)->value;

    if ( !empty($existing_id) ) {
    return $existing_id;
    }

    $user_id = get_current_user_id() ? get_current_user_id() : 1;

    $new_product = array(
    ‘post_author’ => $user_id,
    ‘post_title’ => ‘Taxi Fare’,
    ‘post_status’ => ‘publish’,
    ‘post_type’ => ‘product’
    );

    $post_id = wp_insert_post($new_product);
    update_post_meta($post_id, ‘_stock_status’, ‘instock’);
    update_post_meta($post_id, ‘_visibility’, ‘hidden’);
    //update_post_meta($post_id, ‘_stock’, ”);
    update_post_meta($post_id, ‘_stock’, 1);
    update_post_meta($post_id, ‘_virtual’, ‘yes’);
    //update_post_meta($post_id, ‘_regular_price’, ‘0’);
    update_post_meta($post_id, ‘_regular_price’, $_POST[‘halio_price’]);
    update_post_meta($post_id, ‘_featured’, ‘no’);
    update_post_meta($post_id, ‘_manage_stock’, ‘no’);
    update_post_meta($post_id, ‘_sold_individually’, ‘yes’);
    //update_post_meta($post_id, ‘_price’, ‘0’);
    update_post_meta($post_id, ‘_price’, $_POST[‘halio_price’]);
    return $post_id;
    }

    Then I overrode php file and I ran new order process from affiliate link.
    As a result, in aff_referrals table, amount and reference_amount column of new data were NULL.

    So I guess, in halio_create_wc_product() function, I should code to add meta_key(s) or to update meta_key(s) value for making aff_referrals data.
    If I’m right, how do I code?

  3. Makoto Avatar

    Thank you for reply.
    I seem to be near goal…

    The docs of Halio seems not to exist.
    Instead, Discussion on Halio is https://codecanyon.net/item/halio-woocommerce-taxi-booking-plugin/15490036/comments?page=12
    Now, I don’t know whether Halio provide APIs.
    If I ask to support of Halio about docs and APIs, they might say something…

    Our service has two ways of payment: PayPal and offline payment.
    If user chooses PayPal, when the order data is created as the order status becomes “completed”.
    If user chooses offline payment, after order data is created, when we receive money of taxi fare from travel agency, the admin changes the order status as “completed”.

    According to your reply, the timing of “woocommerce_order_status_completed” seems to be bad.
    Actually, I tried to call at this action hook, but new referral data is created.
    This isn’t what I expect.

    Your reply says “If the fare is completed in WooCommerce then you don’t need to implement anything since this use case is already covered by Affiliates WooCommerce integration.”
    Yes, that’s right.
    I think that he important point is that the creation of new referral data is only one which amount column has taxi fare.

    I think that two ways are here.
    The first. I code to call evaluate function when the order data is created, and code to prevent from calling which plugin might call evaluate function(?) automatically.
    Now I don’t know how to prevent.

    The second. I code to set taxi fare to amount column instead of 0 value before the creation of new referral data.
    This 0 value is product price as I posted first.
    Now I don’t know how and when I override(or set to) amount column.

  4. George Avatar

    Yes almost there.

    Although most parameters are optional I would recommend you to use them for future reference, in order to distinguish your referrals. Especially the last example of evaluate method is pretty explanatory.

    But first things first, you should keep in mind that woocommerce_order_status_completed in your case is probably triggered when the reservation is done. From what you described, I think that you need a hook when the fare is completed( when the ride is completed ) and not when the fare reservation is completed. If the fare is completed in WooCommerce then you don’t need to implement anything since this use case is already covered by Affiliates WooCommerce integration.

    Does Halio provide an API that I can have a look?

    Cheers,
    George

  5. Makoto Avatar

    I might find other way.

    According to your reply, “Regarding the second option, you need a filter or action indicated after the fare is completed successfully.”
    WooCommerce has action hook “woocommerce_order_status_completed”.

    If I code below two lines in this action hook, is it fine to update referral data?
    $r = new Affiliates_Referral_WordPress();
    $r->evaluate($order_id, null, null, null, $total);

    Regards.

  6. Makoto Avatar

    Thank you for replying.
    I choose automatically way.

    The role of Halio is mainly order creation and WooCommerce has role of order processing.
    So the problem is that where and how I call evaluate() function of Affiliates_Referral_WordPress.

    In WooCommerce, WC_Order class has payment_complete() function.
    http://woocommerce.wp-a2z.org/oik_api/wc_orderpayment_complete/

    In this function, if I call like below, the referral data is update, I wonder.
    $r = new Affiliates_Referral_WordPress();
    $r->evaluate( $this->get_id(), null, null, null, $this->get_total());
    According to your explanation, “The only parameter missing is the fare amount”.

    Is my understanding right?

    Regards.

  7. George Avatar

    Hi Makoto,

    In your case, you can add referrals manually or automatically. The only parameter missing is the fare amount. If you can somehow retrieve that amount, then you can either add referrals through Affiliates > Referrals, Add + button, or programmatically the way it is described here.

    Regarding the first option, you need to add a referral manually whenever the fare is completed, which is not very flexible.
    Regarding the second option, you need a filter or action indicated after the fare is completed successfully. This is where you should hook and add a referral programmatically the way it is described in the examples I’ve linked above. Long story short, if Halio supports a feature that indicates that a fare is completed and what was the fare amount, then you can add a referral for that fare.

    Your other option, would be to setup Affiliates Pro with a fixed amount commission, a flat amount that will be granted to each of your affiliates regardless of the fare amount.

    Kind regards,
    George

Share