• Resolved 5 Star Plugins (Rob)

    (@5starplugins)


    The website says Developer Friendly, but there seems to be very sparse and limited action and hook documentation… are there any code samples, PHP client libraries, or examples of implementations? Trying to avoid using webhooks or build out a ton of API calls, or use a web UI like SureTriggers, so hoping a code snippet can detect a paid order or new active subscription, and call a function passing a custom metadata field value.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Andre Gagnon

    (@2winfactor)

    HI There!

    Thanks for reaching out! Happy to help here. We are continually improving our docs, but we have a few code samples and php models you can use.

    It sounds like you might want to check out our Purchase Integration guide. It will allow you to add a new integration that triggers and event when an individual product is purchased.

    https://developer.surecart.com/docs/guide/purchase-integrations/creating

    I’m happy to answer any specific questions you may have with it.

    You can also check out our PHP models, which will let you interact with the SureCart service through PHP:

    https://developer.surecart.com/docs/models/retrieving

    Thread Starter 5 Star Plugins (Rob)

    (@5starplugins)

    Hey @2winfactor I tried the code samples, but it’s not working. I was hoping it’d be similar to:

    add_action(‘surecart/order_paid’, ‘handle_surecart_order_paid’, 10, 2);

    similar to WooCommerce’s order status hook:

    add_action(‘woocommerce_order_status_processing’, ‘handle_woocommerce_order_paid’, 10);

    And then that function is passed the order:

    
    function handle_surecart_order_paid($order, $webhook_data) {
     $orderID = $order->id;
     $customerName = $order->name;
     $customerEmail = $order->email;
    ...
    }

    But that is def not working… I don’t really want an “integration”, I’m looking more for a hook into the plugin and then get the order info.

    I’m also not sure how to programmatically add a checkout form field, like I can do in WooCommerce:

    add_filter('woocommerce_checkout_fields', 'add_my_billing_custom_checkout_field');

    I was hoping there were some flushed out PHP code samples that work, and could then be expanded on.

    I tried the events examples but got errors…

    do_action( 'surecart/purchase_created', (\SureCart\Models\Purchase::class) $purchase, (array) $webhook_data );
    syntax error, unexpected variable "$purchase", expecting ")"
    

    Would love some help or additional resources to get a simple order paid hook working.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Better Actions and Hooks Documentation?’ is closed to new replies.