WP EasyCart API Documentation

Using WordPress Hooks

WP EasyCart implements WordPress hooks in order to allow developers a way to easily customize the core of the plugin. We are always expanding and improving our hooks into the system, so please check back often and contact us if you have a specific need. To learn more about WordPress hooks (actions and filters) please visit WordPress.com.

Product Hooks

Hook Type: Action

Hook Name: wpeasycart_after_product_title

Hook Arguments: NONE

Hook Description: This action is run prior to the description tab display, expects output of an html li to create new tabs within the tab system.

Hook Example Usage:

Within Class: add_action( 'wpeasycart_after_product_title', array( $this, 'my_class_function' ), 10, 1 );

Outside Class: add_action( 'wpeasycart_after_product_title', 'my_custom_function', 10, 1 );

10 = priority value, 1 = number of arguments

function my_custom_function( $product ){

echo 'div' . $product->model_number . '/div'; // HTML tags in text only for display purposes

}

Product Details Hooks

Hook Type: Action

Hook Name: wpeasycart_pre_description_tab

Hook Arguments: NONE

Hook Description: This action is run prior to the description tab display, expects output of an html li to create new tabs within the tab system.

Hook Example Usage:

Within Class: add_action( 'wpeasycart_pre_description_tab', array( $this, 'my_class_function' ), 10, 0 );

Outside Class: add_action( 'wpeasycart_pre_description_tab', 'my_custom_function', 10, 0 );

10 = priority value, 0 = number of arguments

function my_custom_function( ){

echo 'tab here';

}

Hook Type: Action

Hook Name: wpeasycart_pre_specifications_tab

Hook Arguments: NONE

Hook Description: This action is run prior to the specifications tab display, expects output of an html li tag to create new tabs within the tab system.

Hook Example Usage:

Within Class: add_action( 'wpeasycart_pre_specifications_tab', array( $this, 'my_class_function' ), 10, 0 );

Outside Class: add_action( 'wpeasycart_pre_specifications_tab', 'my_custom_function', 10, 0 );

10 = priority value, 0 = number of arguments

function my_custom_function( ){

echo 'tab here'

}

Hook Type: Action

Hook Name: wpeasycart_pre_customer_reviews_tab

Hook Arguments: NONE

Hook Description: This action is run prior to the customer reviews tab display, expects output of an html li tag to create new tabs within the tab system.

Hook Example Usage:

Within Class: add_action( 'wpeasycart_pre_customer_reviews_tab', array( $this, 'my_class_function' ), 10, 0 );

Outside Class: add_action( 'wpeasycart_pre_customer_reviews_tab', 'my_custom_function', 10, 0 );

10 = priority value, 0 = number of arguments

function my_custom_function( ){

echo 'tab here';

}

Hook Type: Action

Hook Name: wpeasycart_addon_product_details_tab

Hook Arguments: NONE

Hook Description: This action is run after the customer review tab outputs and expects output of an li html tag to create new tabs within the tab system.

Hook Example Usage:

Within Class: add_action( 'wpeasycart_addon_product_details_tab', array( $this, 'my_class_function' ), 10, 0 );

Outside Class: add_action( 'wpeasycart_addon_product_details_tab', 'my_custom_function', 10, 0 );

10 = priority value, 0 = number of arguments

function my_custom_function( ){

echo 'tab here';

}

Hook Type: Action

Hook Name: wpeasycart_addon_product_details_tab_content

Hook Arguments: NONE

Hook Description: This action is run prior to the description tab display, expects output of an

  • Tab Name
  • to create new tabs within the tab system.

    Hook Example Usage:

    Within Class: add_action( 'wpeasycart_addon_product_details_tab_content', array( $this, 'my_class_function' ), 10, 0 );

    Outside Class: add_action( 'wpeasycart_addon_product_details_tab_content', 'my_custom_function', 10, 0 );

    10 = priority value, 0 = number of arguments

    function my_custom_function( ){

    echo

    ‘;

    }

    Hook Type: Filter

    Hook Name: wpeasycart_description_initally_active

    Hook Arguments: css_data, product_id

    Hook Description: This filter is run to allow you to initially set the description tab to not active.

    Hook Example Usage:

    Within Class: add_filter( ‘wpeasycart_description_initally_active’, array( $this, ‘my_custom_function’ ), 10, 2 );

    Outside Class: add_filter( ‘wpeasycart_description_initally_active’, ‘my_custom_function’, 10, 2 );

    10 = priority value, 0 = number of arguments

    function my_custom_function( $css_active, $product_id ){

    return “”; // non-active description tab, return $css_active if you want to leave unchanged or add to it for customizing class.

    }

    Hook Type: Filter

    Hook Name: wpeasycart_description_content_initally_active

    Hook Arguments: html_data, product_id

    Hook Description: This filter is run to allow you to initially set the description tab to not active.

    Hook Example Usage:

    Within Class: add_filter( ‘wpeasycart_description_content_initally_active’, array( $this, ‘my_custom_function’ ), 10, 2 );

    Outside Class: add_filter( ‘wpeasycart_description_initally_active’, ‘my_custom_function’, 10, 2 );

    10 = priority value, 0 = number of arguments

    function my_custom_function( $html_active, $product_id ){

    return “style=’display:none;'”; // hide description content, return $html_active if you want to leave unchanged or add to it for customizing class.

    }

    Hook Type: Filter

    Hook Name: wpeasycart_allowed_file_upload_types

    Hook Arguments: FileTypes

    Hook Description: This filter allows you to modify the accepted MIME file types for the advanced option type ‘File Upload’. Default values are array( ‘text/plain’, ‘image/jpeg’, ‘image/png’, ‘image/gif’, ‘application/pdf’, ‘application/x-compressed’, ‘application/x-zip-compressed’, ‘application/zip’, ‘multipart/x-zip’, ‘application/x-bzip2’, ‘application/x-bzip’, ‘application/x-bzip2’, ‘application/x-gzip’, ‘application/x-gzip’, ‘multipart/x-gzip’ );

    Hook Example Usage:

    Within Class: add_filter( ‘wpeasycart_allowed_file_upload_types’, array( $this, ‘my_custom_function’ ), 10, 1 );

    Outside Class: add_filter( ‘wpeasycart_allowed_file_upload_types’, ‘my_custom_function’, 10, 1 );

    10 = priority value, 1 = number of arguments

    function my_custom_function( $fileTypes ){

    $fileTypes[] = “application/x-shockwave-flash”;

    return $fileTypes;

    }

    Cart Actions

    Hook Type: Action

    Hook Name: wpeasycart_cart_updated

    Hook Arguments: NONE

    Hook Description: This action is run immediately after an item is added to the cart OR a quantity amount is updated in the cart OR an item is deleted from the cart.

    Hook Example Usage:

    Within Class: add_action( 'wpeasycart_cart_updated', array( $this, 'my_class_function' ), 10, 0 );

    Outside Class: add_action( 'wpeasycart_cart_updated', 'my_custom_function', 10, 0 );

    10 = priority value, 0 = number of arguments

    function my_custom_function( ){

    $user = new ec_user( '' );

    recalculate_shipping_totals( $user->shipping->address_line_1 . " " . $user->shipping->city . ", " . $user->shipping->state . " " . $user->shipping->zip . " " . $user->shipping->country );

    }

    Hook Type: Filter

    Hook Name: wpeasycart_validate_checkout_data

    Hook Arguments: data_validated (Bool), user (ec_user)

    Hook Description: This filter allows you to add custom validation to the php side of the checkout system.

    Hook Example Usage:

    Within Class: add_filter( 'wpeasycart_validate_checkout_data', array( $this, 'my_class_function' ), 10, 2 );

    Outside Class: add_filter( 'wpeasycart_validate_checkout_data', 'my_custom_function', 10, 2 );

    10 = priority value, 0 = number of arguments

    function my_custom_function( $validated, $user ){

    if( strlen( trim( $user->billing->state ) ) != 2 )

    return false

    if( strlen( trim( $user->billing->zip ) ) != 5 )

    return false

    return $validated

    }

    Hook Type: Filter

    Hook Name: wpeasycart_validate_submit_order_data

    Hook Arguments: data_validated (Bool), user (ec_user)

    Hook Description: This filter allows you to add custom validation to the php side of the checkout system immediately before the order is submitted.

    Hook Example Usage:

    Within Class: add_filter( 'wpeasycart_validate_submit_order_data', array( $this, 'my_class_function' ), 10, 2 );

    Outside Class: add_filter( 'wpeasycart_validate_submit_order_data', 'my_custom_function', 10, 2 );

    10 = priority value, 0 = number of arguments

    function my_custom_function( $validated, $user ){

    if( strlen( trim( $user->billing->state ) ) != 2 )

    return false

    if( strlen( trim( $user->billing->zip ) ) != 5 )

    return false

    return $validated

    }

    Hook Type: Action

    Hook Name: wpeasycart_order_inserted

    Hook Arguments: 

    • order_id (number)
    • cart (ec_cart class)
    • order_totals (ec_order_totals class)
    • user (ec_user class)
    • payment_type (string)

    Hook Description: This action is run right after the order is inserted and the process result is returned as valid. This applies to a credit card payment completed, a third party payment started or a direct deposit order inserted. This does not mean payment has been received in all cases.

    Hook Example Usage:

    Within Class: add_action( 'wpeasycart_order_inserted', array( $this, 'my_class_function' ), 10, 5 );

    Outside Class: add_action( 'wpeasycart_order_inserted', 'my_custom_function', 10, 5 );

    10 = priority value, 5 = number of arguments

    function my_custom_function( $order_id, $cart, $order_totals, $user, $payment_type ){

    insert_into_my_pos_system( $order_id, $order_totals->grand_total, $user->user_id, $payment_type );

    send_custom_email( $user->email );

    }

    Hook Type: Action

    Hook Name: wpeasycart_order_paid

    Hook Arguments: 

    • order_id (number)

    Hook Description: This action is run right after the order is paid and applies to live credit card payments and changes to the order status in the store admin console.

    Hook Example Usage:

    Within Class: add_action( 'wpeasycart_order_paid', array( $this, 'my_class_function' ), 10, 1 );

    Outside Class: add_action( 'wpeasycart_order_paid', 'my_custom_function', 10, 1 );

    10 = priority value, 1 = number of arguments

    function my_custom_function( $order_id ){

    update_my_pos_system( $order_id, 'paid' );

    }

    Hook Type: Action

    Hook Name: wpeasycart_order_shipped

    Hook Arguments: 

    • order_id (number)

    Hook Description: This action is run when an order status is updated to shipped from within the admin console.

    Hook Example Usage:

    Within Class: add_action( 'wpeasycart_order_shipped', array( $this, 'my_class_function' ), 10, 1 );

    Outside Class: add_action( 'wpeasycart_order_shipped', 'my_custom_function', 10, 1 );

    10 = priority value, 1 = number of arguments

    function my_custom_function( $order_id ){

    update_my_pos_system( $order_id, 'shipped' );

    }

    Hook Type: Action

    Hook Name: wpeasycart_partial_order_refund

    Hook Arguments: 

    • order_id (number)
    • refund_amount (float) – amount refunded this time, available when partially refunding through the admin console.
    • refund_total (float) – amount refunded so far (multiple refunds possible), available when partially refunding through the admin console.

    Hook Description: This action is run right after the order is paid and applies to live credit card payments and changes to the order status in the store admin console.

    Hook Example Usage:

    Within Class: add_action( 'wpeasycart_partial_order_refund', array( $this, 'my_class_function' ), 10, 3 );

    Outside Class: add_action( 'wpeasycart_partial_order_refund', 'my_custom_function', 10, 3 );

    10 = priority value, 3 = number of arguments

    function my_custom_function( $order_id, $this_refund_amount, $total_refund_amount ){

    update_my_post_system( $order_id, 'partial refund', $total_refund_amount );

    }

    Hook Type: Action

    Hook Name: wpeasycart_full_order_refund

    Hook Arguments: 

    • order_id (number)

    Hook Description: This action is run when the admin console updates the order status to full refund OR when the refund button is called from the admin console and refund is successfully issued OR when a webhook or IPN hits the EasyCart to notify of a full refund.

    Hook Example Usage:

    Within Class: add_action( 'wpeasycart_full_order_refund', array( $this, 'my_class_function' ), 10, 1 );

    Outside Class: add_action( 'wpeasycart_full_order_refund', 'my_custom_function', 10, 1 );

    10 = priority value, 1 = number of arguments

    function my_custom_function( $order_id ){

    update_my_post_system( $order_id, 'refunded' );

    }

    Hook Type: Action

    Hook Name: wpeasycart_success_page_content_top

    Hook Arguments: 

    • order_id (number)
    • order (ec_order)

    Hook Description: This action is run at the top of the cart success page, allowing you to add scripts or additional content at the top of the cart success page.

    Hook Example Usage:

    Within Class: add_action( 'wpeasycart_success_page_content_top', array( $this, 'my_class_function' ), 10, 2 );

    Outside Class: add_action( 'wpeasycart_success_page_content_top', 'my_custom_function', 10, 2 );

    10 = priority value, 2 = number of arguments

    function my_custom_function( $order_id, $order ){

        echo "put script here for anything from third party code to additional content for the user on successful purchase.";

    }

    Email Based Hooks

    Hook Type: Filter

    Hook Name: wpeasycart_email_method

    Hook Return Values: 

    • email method (string): 2 = custom method, 1 = wp_mail function, 0 = php mail function

    Hook Description: This filter allows you to implement your own custom email system. If you decide to customize your email system, filter the email method and return 2 then implement ALL actions in this section.

    Hook Example Usage:

    Within Class: add_filter( 'wpeasycart_email_method', array( $this, 'set_custom_email_method' ) );

    Outside Class: add_filter( 'wpeasycart_email_method', 'set_custom_email_method' );

    function set_custom_email_method( );

    return "2";

    }

    Hook Type: Action

    Hook Name: wpeasycart_custom_order_email

    Hook Arguments: 

    • from_email (string) – the email address setup in your EasyCart basic settings to apply to email receipts for this message.
    • to_email (string) – the customer’s email address entered on checkout.
    • admin_emails (string) – the admin email addresses setup in your EasyCart basic settings to be used to send copies of the email receipt.
    • wpeasycart_title (string) – the subject line for the email.
    • wpeasycart_message (string) – the message for the receipt.

    Hook Description: This action is run when the email is filtered to use a custom email type and when the order receipt is supposed to be sent out. This occurs when a live payment is completed OR a third party payment is completed OR a manual billing order is submitted. This is also run when you use the store status, resend order email option from the EasyCart admin -> dashboard in your WordPress admin.

    Hook Example Usage:

    Within Class: add_action( 'wpeasycart_custom_order_email', array( $this, 'send_custom_order_email' ), 10, 5 );

    Outside Class: add_action( 'wpeasycart_custom_order_email', 'send_custom_order_email', 10, 5 );

    10 = priority value, 5 = number of arguments

    function send_custom_order_email( $from_email, $to_email, $admin_emails, $wpeasycart_title, $wpeasycart_message ){

    custom_send_email( $from_email, $to_email, $admin_emails, $wpeasycart_title, $wpeasycart_message, "order-receipt" );

    }

    Hook Type: Action

    Hook Name: wpeasycart_custom_subscription_order_email

    Hook Arguments: 

    • from_email (string) – the email address setup in your EasyCart basic settings to apply to email receipts for this message.
    • to_email (string) – the customer’s email address entered on checkout.
    • admin_emails (string) – the admin email addresses setup in your EasyCart basic settings to be used to send copies of the email receipt.
    • wpeasycart_title (string) – the subject line for the email.
    • wpeasycart_message (string) – the message for the receipt.

    Hook Description: This action is run when the email is filtered to use a custom email type and when the order receipt is supposed to be sent out. This occurs when a live payment is completed with Stripe only. This is also run when you use the store status, resend order email option from the EasyCart admin -> dashboard in your WordPress admin.

    Hook Example Usage:

    Within Class: add_action( 'wpeasycart_custom_subscription_order_email', array( $this, 'send_custom_order_email' ), 10, 5 );

    Outside Class: add_action( 'wpeasycart_custom_subscription_order_email', 'send_custom_order_email', 10, 5 );

    10 = priority value, 5 = number of arguments

    function send_custom_order_email( $from_email, $to_email, $admin_emails, $wpeasycart_title, $wpeasycart_message ){

    custom_send_email( $from_email, $to_email, $admin_emails, $wpeasycart_title, $wpeasycart_message, "subscription-receipt" );

    }

    Hook Type: Action

    Hook Name: wpeasycart_custom_forgot_password_email

    Hook Arguments: 

    • from_email (string) – the email address setup in your EasyCart basic settings to apply to forgot password emails.
    • to_email (string) – the customer’s email address entered on checkout.
    • admin_emails – EMPTY STRING FOR THIS TYPE OF EMAIL
    • wpeasycart_title (string) – the subject line for the email.
    • wpeasycart_message (string) – the message for the receipt.

    Hook Description: This action runs when you filter to a custom email method and customer submits a request to reset their password.

    Hook Example Usage:

    Within Class: add_action( 'wpeasycart_custom_forgot_password_email', array( $this, 'send_custom_email' ), 10, 5 );

    Outside Class: add_action( 'wpeasycart_custom_forgot_password_email', 'send_custom_email', 10, 5 );

    10 = priority value, 5 = number of arguments

    function send_custom_email( $from_email, $to_email, $admin_emails, $wpeasycart_title, $wpeasycart_message ){

    custom_send_email( $from_email, $to_email, $admin_emails, $wpeasycart_title, $wpeasycart_message, "order-receipt" );

    }

    Hook Type: Action

    Hook Name: wpeasycart_custom_register_verification_email

    Hook Arguments: 

    • from_email (string) – the email address setup in your EasyCart basic settings to apply to password recovery emailers.
    • to_email (string) – the customer’s email address entered on checkout.
    • admin_emails – EMPTY STRING FOR THIS ACTION
    • wpeasycart_title (string) – the subject line for the email.
    • wpeasycart_message (string) – the message for the receipt.

    Hook Description: This action is run when the email is filtered to use a custom email type and a user signs up when you require them to validate their email before accessing their account.

    Hook Example Usage:

    Within Class: add_action( 'wpeasycart_custom_register_verification_email', array( $this, 'send_custom_email' ), 10, 5 );

    Outside Class: add_action( 'wpeasycart_custom_register_verification_email', 'send_custom_email', 10, 5 );

    10 = priority value, 5 = number of arguments

    function send_custom_email( $from_email, $to_email, $admin_emails, $wpeasycart_title, $wpeasycart_message ){

    custom_send_email( $from_email, $to_email, $admin_emails, $wpeasycart_title, $wpeasycart_message, "order-receipt" );

    }

    Hook Type: Action

    Hook Name: wpeasycart_custom_gift_card_email

    Hook Arguments: 

    • from_email (string) – the email address setup in your EasyCart basic settings to apply to email receipts for this message.
    • to_email (string) – the customer’s email address entered on checkout.
    • admin_emails (string) – the admin email addresses setup in your EasyCart basic settings to be used to send copies of the email receipt.
    • wpeasycart_title (string) – the subject line for the email.
    • wpeasycart_message (string) – the message for the receipt.

    Hook Description: This action is run when the email is filtered to use a custom email type and when the order receipt is supposed to be sent out. This occurs when a live payment is completed OR a third party payment is completed OR a manual billing order is submitted. This is also run when you use the store status, resend order email option from the EasyCart admin -> dashboard in your WordPress admin.

    Hook Example Usage:

    Within Class: add_action( 'wpeasycart_custom_gift_card_email', array( $this, 'send_custom_email' ), 10, 5 );

    Outside Class: add_action( 'wpeasycart_custom_gift_card_email', 'send_custom_email', 10, 5 );

    10 = priority value, 5 = number of arguments

    function send_custom_email( $from_email, $to_email, $admin_emails, $wpeasycart_title, $wpeasycart_message ){

    custom_send_email( $from_email, $to_email, $admin_emails, $wpeasycart_title, $wpeasycart_message, "order-receipt" );

    }

    Hook Type: Action

    Hook Name: wpeasycart_custom_inquiry_email

    Hook Arguments: 

    • from_email (string) – the email address setup in your EasyCart basic settings to apply to email receipts for this message.
    • to_email (string) – the customer’s email address entered on checkout.
    • admin_emails (string) – the admin email addresses setup in your EasyCart basic settings to be used to send copies of the email receipt.
    • wpeasycart_title (string) – the subject line for the email.
    • wpeasycart_message (string) – the message for the receipt.

    Hook Description: This action is run when the email is filtered to use a custom email type and when an inquiry email is supposed to be sent out.

    Hook Example Usage:

    Within Class: add_action( 'wpeasycart_custom_inquiry_email', array( $this, 'send_custom_email' ), 10, 5 );

    Outside Class: add_action( 'wpeasycart_custom_inquiry_email', 'send_custom_email', 10, 5 );

    10 = priority value, 5 = number of arguments

    function send_custom_email( $from_email, $to_email, $admin_emails, $wpeasycart_title, $wpeasycart_message ){

    custom_send_email( $from_email, $to_email, $admin_emails, $wpeasycart_title, $wpeasycart_message, "order-receipt" );

    }

    Account Menu Actions

    Hook Type: Action

    Hook Name: wpeasycart_account_links

    Hook Arguments: NONE

    Hook Description: This action is run prior to loading other menu items.

    Hook Example Usage:

    add_action( 'wpeasycart_account_links', 'add_custom_links', 10, 0 );

    function add_custom_links( ){

    echo "Custom Account Content";

    }

    Account Order Detail Line Item Actions

    Hook Type: Action

    Hook Name: wpeasycart_order_detail_line_item

    Hook Arguments: NONE

    Hook Description: This action is run after printing the order details detail line item details information.

    Hook Example Usage:

    add_action( 'wpeasycart_order_detail_line_item', 'add_custom_content', 10, 0 );

    function add_custom_content( ){

    echo 'get 25% off your next order with coupon123 on checkout!';

    }

    Hook Type: Action

    Hook Name: wpeasycart_email_receipt_line_item

    Hook Arguments: NONE

    Hook Description: This action is run after printing the email receipt detail line item details information.

    Hook Example Usage:

    add_action( 'wpeasycart_email_receipt_line_item', 'add_custom_content', 10, 1 );

    function add_custom_content( $model_number ){

    echo 'get 25% off your next order with coupon123 on checkout!';

    }

    Hook Type: Action

    Hook Name: wpeasycart_subscription_email_receipt_line_item

    Hook Arguments: NONE

    Hook Description: This action is run after printing the line item details.

    Hook Example Usage:

    add_action( 'wpeasycart_subscription_email_receipt_line_item', 'add_custom_content', 10, 0 );

    function add_custom_content( ){

    echo 'get 25% off your next order with coupon123 on checkout!';

    }

    Admin Actions

    Hook Type: Action

    Hook Name: wpeasycart_admin_advanced_options

    Hook Arguments: NONE

    Hook Description: This action is run at the end of the advanced options page in the admin and allows a developer to add options for their EasyCart extension plugin.

    Hook Example Usage:

    add_action( 'admin_init', 'wpeasycart_load_custom_admin_hooks' );

    function wpeasycart_load_custom_admin_hooks( ){

    add_action( 'wpeasycart_admin_advanced_options', 'add_advanced_option_form_items', 10, 0 );

    }

    function add_advanced_option_form_items( ){

    echo 'put your form items here'

    }

    Hook Type: Action

    Hook Name: wpeasycart_admin_process_advanced_options

    Hook Arguments: NONE

    Hook Description: This is to be used in combination with the add_advanced_option_form_items hook to save those custom options.

    Hook Example Usage:

    add_action( 'admin_init', 'wpeasycart_load_custom_admin_hooks' );

    function wpeasycart_load_custom_admin_hooks( ){

    add_action( 'wpeasycart_admin_process_advanced_options', 'add_advanced_option_form_items', 10, 0 );

    }

    function add_advanced_option_form_items( ){

    update_option( 'ec_option_my_custom_field', $_POST['ec_option_my_custom_field'] );

    }