WooCommerce Code Reference

Search results

WC_AJAX

WC_Ajax class.

Table of Contents

init() Hook in ajax handlers. mixed
get_endpoint() Get WC Ajax Endpoint. string
define_ajax() Set WC AJAX constant and headers. mixed
wc_ajax_headers() Send headers for WC Ajax Requests. mixed
do_wc_ajax() Check for WC Ajax request and fire action. mixed
add_ajax_events() Hook in methods - uses WordPress ajax handlers (admin-ajax). mixed
get_refreshed_fragments() Get a refreshed cart fragment, including the mini cart HTML. mixed
apply_coupon() AJAX apply coupon on checkout page. mixed
remove_coupon() AJAX remove coupon on cart and checkout page. mixed
update_shipping_method() AJAX update shipping method on cart page. mixed
get_cart_totals() AJAX receive updated cart_totals div. mixed
update_order_review_expired() Session has expired. mixed
update_order_review() AJAX update order review on checkout. mixed
add_to_cart() AJAX add to cart. mixed
remove_from_cart() AJAX remove from cart. mixed
checkout() Process ajax checkout form. mixed
get_variation() Get a matching variation based on posted attributes. mixed
get_customer_location() Locate user via AJAX. mixed
feature_product() Toggle Featured status of a product from admin. mixed
mark_order_status() Mark an order with a status. mixed
get_order_details() Get order details. mixed
add_attribute() Add an attribute row. mixed
add_new_attribute() Add a new attribute via ajax function. mixed
remove_variations() Delete variations via ajax function. mixed
save_attributes() Save attributes via ajax. mixed
add_variation() Add variation via ajax function. mixed
link_all_variations() Link all variations via ajax function. mixed
revoke_access_to_download() Delete download permissions via ajax function. mixed
grant_access_to_download() Grant download permissions via ajax function. mixed
get_customer_details() Get customer details via ajax. mixed
add_order_item() Add order item via ajax. Used on the edit order screen in WP Admin. mixed
add_order_fee() Add order fee via ajax. mixed
add_order_shipping() Add order shipping cost via ajax. mixed
add_order_tax() Add order tax column via ajax. mixed
add_coupon_discount() Add order discount via ajax. mixed
remove_order_coupon() Remove coupon from an order via ajax. mixed
remove_order_item() Remove an order item. mixed
remove_order_tax() Remove an order tax. mixed
calc_line_taxes() Calc line tax. mixed
save_order_items() Save order items via ajax. mixed
load_order_items() Load order items via ajax. mixed
add_order_note() Add order note via ajax. mixed
delete_order_note() Delete order note via ajax. mixed
json_search_products() Search for products and echo json. mixed
json_search_products_and_variations() Search for product variations and return json. mixed
json_search_downloadable_products_and_variations() Search for downloadable product variations and return json. mixed
json_search_customers() Search for customers and return json. mixed
json_search_categories() Search for categories and return json. mixed
term_ordering() Ajax request handling for categories ordering. mixed
product_ordering() Ajax request handling for product ordering. mixed
refund_line_items() Handle a refund via the edit order screen. mixed
delete_refund() Delete a refund. mixed
rated() Triggered when clicking the rating footer. mixed
update_api_key() Create/Update API key. mixed
load_variations() Load variations via AJAX. mixed
save_variations() Save variations via AJAX. mixed
variation_bulk_action_toggle_enabled() Bulk action - Toggle Enabled. mixed
variation_bulk_action_toggle_downloadable() Bulk action - Toggle Downloadable Checkbox. mixed
variation_bulk_action_toggle_virtual() Bulk action - Toggle Virtual Checkbox. mixed
variation_bulk_action_toggle_manage_stock() Bulk action - Toggle Manage Stock Checkbox. mixed
variation_bulk_action_variable_regular_price() Bulk action - Set Regular Prices. mixed
variation_bulk_action_variable_sale_price() Bulk action - Set Sale Prices. mixed
variation_bulk_action_variable_stock_status_instock() Bulk action - Set Stock Status as In Stock. mixed
variation_bulk_action_variable_stock_status_outofstock() Bulk action - Set Stock Status as Out of Stock. mixed
variation_bulk_action_variable_stock_status_onbackorder() Bulk action - Set Stock Status as On Backorder. mixed
variation_bulk_action_variable_stock() Bulk action - Set Stock. mixed
variation_bulk_action_variable_weight() Bulk action - Set Weight. mixed
variation_bulk_action_variable_length() Bulk action - Set Length. mixed
variation_bulk_action_variable_width() Bulk action - Set Width. mixed
variation_bulk_action_variable_height() Bulk action - Set Height. mixed
variation_bulk_action_variable_download_limit() Bulk action - Set Download Limit. mixed
variation_bulk_action_variable_download_expiry() Bulk action - Set Download Expiry. mixed
variation_bulk_action_delete_all() Bulk action - Delete all. mixed
variation_bulk_action_variable_sale_schedule() Bulk action - Sale Schedule. mixed
variation_bulk_action_variable_regular_price_increase() Bulk action - Increase Regular Prices. mixed
variation_bulk_action_variable_regular_price_decrease() Bulk action - Decrease Regular Prices. mixed
variation_bulk_action_variable_sale_price_increase() Bulk action - Increase Sale Prices. mixed
variation_bulk_action_variable_sale_price_decrease() Bulk action - Decrease Sale Prices. mixed
variation_bulk_adjust_price() Bulk action - Set Price. mixed
variation_bulk_set() Bulk set convenience function. mixed
variation_bulk_toggle() Bulk toggle convenience function. mixed
bulk_edit_variations() Bulk edit variations via AJAX. mixed
tax_rates_save_changes() Handle submissions from assets/js/settings-views-html-settings-tax.js Backbone model. mixed
shipping_zones_save_changes() Handle submissions from assets/js/wc-shipping-zones.js Backbone model. mixed
shipping_zone_add_method() Handle submissions from assets/js/wc-shipping-zone-methods.js Backbone model. mixed
shipping_zone_methods_save_changes() Handle submissions from assets/js/wc-shipping-zone-methods.js Backbone model. mixed
shipping_zone_methods_save_settings() Save method settings mixed
shipping_classes_save_changes() Handle submissions from assets/js/wc-shipping-classes.js Backbone model. mixed
toggle_gateway_enabled() Toggle payment gateway on or off via AJAX. mixed

Methods

init()

Hook in ajax handlers.

public static init( ) : mixed
Return values
mixed

get_endpoint()

Get WC Ajax Endpoint.

public static get_endpoint( [ $request : string = '' ] ) : string
Parameters
$request : string = ''

Optional.

Return values
string

define_ajax()

Set WC AJAX constant and headers.

public static define_ajax( ) : mixed
Return values
mixed

wc_ajax_headers()

Send headers for WC Ajax Requests.

private static wc_ajax_headers( ) : mixed
Tags
since
Return values
mixed

do_wc_ajax()

Check for WC Ajax request and fire action.

public static do_wc_ajax( ) : mixed
Return values
mixed

add_ajax_events()

Hook in methods - uses WordPress ajax handlers (admin-ajax).

public static add_ajax_events( ) : mixed
Return values
mixed

get_refreshed_fragments()

Get a refreshed cart fragment, including the mini cart HTML.

public static get_refreshed_fragments( ) : mixed
Return values
mixed

apply_coupon()

AJAX apply coupon on checkout page.

public static apply_coupon( ) : mixed
Return values
mixed

remove_coupon()

AJAX remove coupon on cart and checkout page.

public static remove_coupon( ) : mixed
Return values
mixed

update_shipping_method()

AJAX update shipping method on cart page.

public static update_shipping_method( ) : mixed
Return values
mixed

get_cart_totals()

AJAX receive updated cart_totals div.

public static get_cart_totals( ) : mixed
Return values
mixed

update_order_review_expired()

Session has expired.

private static update_order_review_expired( ) : mixed
Return values
mixed

update_order_review()

AJAX update order review on checkout.

public static update_order_review( ) : mixed
Return values
mixed

add_to_cart()

AJAX add to cart.

public static add_to_cart( ) : mixed
Return values
mixed

remove_from_cart()

AJAX remove from cart.

public static remove_from_cart( ) : mixed
Return values
mixed

checkout()

Process ajax checkout form.

public static checkout( ) : mixed
Return values
mixed

get_variation()

Get a matching variation based on posted attributes.

public static get_variation( ) : mixed
Return values
mixed

get_customer_location()

Locate user via AJAX.

public static get_customer_location( ) : mixed
Return values
mixed

feature_product()

Toggle Featured status of a product from admin.

public static feature_product( ) : mixed
Return values
mixed

mark_order_status()

Mark an order with a status.

public static mark_order_status( ) : mixed
Return values
mixed

get_order_details()

Get order details.

public static get_order_details( ) : mixed
Return values
mixed

add_attribute()

Add an attribute row.

public static add_attribute( ) : mixed
Return values
mixed

add_new_attribute()

Add a new attribute via ajax function.

public static add_new_attribute( ) : mixed
Return values
mixed

remove_variations()

Delete variations via ajax function.

public static remove_variations( ) : mixed
Return values
mixed

save_attributes()

Save attributes via ajax.

public static save_attributes( ) : mixed
Return values
mixed

add_variation()

Add variation via ajax function.

public static add_variation( ) : mixed
Return values
mixed

link_all_variations()

Link all variations via ajax function.

public static link_all_variations( ) : mixed
Return values
mixed

revoke_access_to_download()

Delete download permissions via ajax function.

public static revoke_access_to_download( ) : mixed
Return values
mixed

grant_access_to_download()

Grant download permissions via ajax function.

public static grant_access_to_download( ) : mixed
Return values
mixed

get_customer_details()

Get customer details via ajax.

public static get_customer_details( ) : mixed
Return values
mixed

add_order_item()

Add order item via ajax. Used on the edit order screen in WP Admin.

public static add_order_item( ) : mixed
Tags
throws

If order is invalid.

Return values
mixed

add_order_fee()

Add order fee via ajax.

public static add_order_fee( ) : mixed
Tags
throws

If order is invalid.

Return values
mixed

add_order_shipping()

Add order shipping cost via ajax.

public static add_order_shipping( ) : mixed
Tags
throws

If order is invalid.

Return values
mixed

add_order_tax()

Add order tax column via ajax.

public static add_order_tax( ) : mixed
Tags
throws

If order or tax rate is invalid.

Return values
mixed

add_coupon_discount()

Add order discount via ajax.

public static add_coupon_discount( ) : mixed
Tags
throws

If order or coupon is invalid.

Return values
mixed

remove_order_coupon()

Remove coupon from an order via ajax.

public static remove_order_coupon( ) : mixed
Tags
throws

If order or coupon is invalid.

Return values
mixed

remove_order_item()

Remove an order item.

public static remove_order_item( ) : mixed
Tags
throws

If order is invalid.

Return values
mixed

remove_order_tax()

Remove an order tax.

public static remove_order_tax( ) : mixed
Tags
throws

If there is an error whilst deleting the rate.

Return values
mixed

calc_line_taxes()

Calc line tax.

public static calc_line_taxes( ) : mixed
Return values
mixed

save_order_items()

Save order items via ajax.

public static save_order_items( ) : mixed
Return values
mixed

load_order_items()

Load order items via ajax.

public static load_order_items( ) : mixed
Return values
mixed

add_order_note()

Add order note via ajax.

public static add_order_note( ) : mixed
Return values
mixed

delete_order_note()

Delete order note via ajax.

public static delete_order_note( ) : mixed
Return values
mixed

json_search_products()

Search for products and echo json.

public static json_search_products( [ $term : string = '' ] [, $include_variations : bool = false ] ) : mixed
Parameters
$term : string = ''

(default: '') Term to search for.

$include_variations : bool = false

in search or not.

Return values
mixed

json_search_products_and_variations()

Search for product variations and return json.

public static json_search_products_and_variations( ) : mixed
Tags
see
Return values
mixed

json_search_downloadable_products_and_variations()

Search for downloadable product variations and return json.

public static json_search_downloadable_products_and_variations( ) : mixed
Tags
see
Return values
mixed

json_search_customers()

Search for customers and return json.

public static json_search_customers( ) : mixed
Return values
mixed

json_search_categories()

Search for categories and return json.

public static json_search_categories( ) : mixed
Return values
mixed

term_ordering()

Ajax request handling for categories ordering.

public static term_ordering( ) : mixed
Return values
mixed

refund_line_items()

Handle a refund via the edit order screen.

public static refund_line_items( ) : mixed
Tags
throws

To return errors.

Return values
mixed

delete_refund()

Delete a refund.

public static delete_refund( ) : mixed
Return values
mixed

rated()

Triggered when clicking the rating footer.

public static rated( ) : mixed
Return values
mixed

update_api_key()

Create/Update API key.

public static update_api_key( ) : mixed
Tags
throws

On invalid or empty description, user, or permissions.

Return values
mixed

load_variations()

Load variations via AJAX.

public static load_variations( ) : mixed
Return values
mixed

save_variations()

Save variations via AJAX.

public static save_variations( ) : mixed
Return values
mixed

variation_bulk_action_toggle_enabled()

Bulk action - Toggle Enabled.

private static variation_bulk_action_toggle_enabled( $variations : array , $data : array ) : mixed
Parameters
$variations : array

List of variations.

$data : array

Data to set.

Tags
used-by

bulk_edit_variations

Return values
mixed

variation_bulk_action_toggle_downloadable()

Bulk action - Toggle Downloadable Checkbox.

private static variation_bulk_action_toggle_downloadable( $variations : array , $data : array ) : mixed
Parameters
$variations : array

List of variations.

$data : array

Data to set.

Tags
used-by

bulk_edit_variations

Return values
mixed

variation_bulk_action_toggle_virtual()

Bulk action - Toggle Virtual Checkbox.

private static variation_bulk_action_toggle_virtual( $variations : array , $data : array ) : mixed
Parameters
$variations : array

List of variations.

$data : array

Data to set.

Tags
used-by

bulk_edit_variations

Return values
mixed

variation_bulk_action_toggle_manage_stock()

Bulk action - Toggle Manage Stock Checkbox.

private static variation_bulk_action_toggle_manage_stock( $variations : array , $data : array ) : mixed
Parameters
$variations : array

List of variations.

$data : array

Data to set.

Tags
used-by

bulk_edit_variations

Return values
mixed

variation_bulk_action_variable_regular_price()

Bulk action - Set Regular Prices.

private static variation_bulk_action_variable_regular_price( $variations : array , $data : array ) : mixed
Parameters
$variations : array

List of variations.

$data : array

Data to set.

Tags
used-by

bulk_edit_variations

Return values
mixed

variation_bulk_action_variable_sale_price()

Bulk action - Set Sale Prices.

private static variation_bulk_action_variable_sale_price( $variations : array , $data : array ) : mixed
Parameters
$variations : array

List of variations.

$data : array

Data to set.

Tags
used-by

bulk_edit_variations

Return values
mixed

variation_bulk_action_variable_stock_status_instock()

Bulk action - Set Stock Status as In Stock.

private static variation_bulk_action_variable_stock_status_instock( $variations : array , $data : array ) : mixed
Parameters
$variations : array

List of variations.

$data : array

Data to set.

Tags
used-by

bulk_edit_variations

Return values
mixed

variation_bulk_action_variable_stock_status_outofstock()

Bulk action - Set Stock Status as Out of Stock.

private static variation_bulk_action_variable_stock_status_outofstock( $variations : array , $data : array ) : mixed
Parameters
$variations : array

List of variations.

$data : array

Data to set.

Tags
used-by

bulk_edit_variations

Return values
mixed

variation_bulk_action_variable_stock_status_onbackorder()

Bulk action - Set Stock Status as On Backorder.

private static variation_bulk_action_variable_stock_status_onbackorder( $variations : array , $data : array ) : mixed
Parameters
$variations : array

List of variations.

$data : array

Data to set.

Tags
used-by

bulk_edit_variations

Return values
mixed

variation_bulk_action_variable_stock()

Bulk action - Set Stock.

private static variation_bulk_action_variable_stock( $variations : array , $data : array ) : mixed
Parameters
$variations : array

List of variations.

$data : array

Data to set.

Tags
used-by

bulk_edit_variations

Return values
mixed

variation_bulk_action_variable_weight()

Bulk action - Set Weight.

private static variation_bulk_action_variable_weight( $variations : array , $data : array ) : mixed
Parameters
$variations : array

List of variations.

$data : array

Data to set.

Tags
used-by

bulk_edit_variations

Return values
mixed

variation_bulk_action_variable_length()

Bulk action - Set Length.

private static variation_bulk_action_variable_length( $variations : array , $data : array ) : mixed
Parameters
$variations : array

List of variations.

$data : array

Data to set.

Tags
used-by

bulk_edit_variations

Return values
mixed

variation_bulk_action_variable_width()

Bulk action - Set Width.

private static variation_bulk_action_variable_width( $variations : array , $data : array ) : mixed
Parameters
$variations : array

List of variations.

$data : array

Data to set.

Tags
used-by

bulk_edit_variations

Return values
mixed

variation_bulk_action_variable_height()

Bulk action - Set Height.

private static variation_bulk_action_variable_height( $variations : array , $data : array ) : mixed
Parameters
$variations : array

List of variations.

$data : array

Data to set.

Tags
used-by

bulk_edit_variations

Return values
mixed

variation_bulk_action_variable_download_limit()

Bulk action - Set Download Limit.

private static variation_bulk_action_variable_download_limit( $variations : array , $data : array ) : mixed
Parameters
$variations : array

List of variations.

$data : array

Data to set.

Tags
used-by

bulk_edit_variations

Return values
mixed

variation_bulk_action_variable_download_expiry()

Bulk action - Set Download Expiry.

private static variation_bulk_action_variable_download_expiry( $variations : array , $data : array ) : mixed
Parameters
$variations : array

List of variations.

$data : array

Data to set.

Tags
used-by

bulk_edit_variations

Return values
mixed

variation_bulk_action_delete_all()

Bulk action - Delete all.

private static variation_bulk_action_delete_all( $variations : array , $data : array ) : mixed
Parameters
$variations : array

List of variations.

$data : array

Data to set.

Tags
used-by

bulk_edit_variations

Return values
mixed

variation_bulk_action_variable_sale_schedule()

Bulk action - Sale Schedule.

private static variation_bulk_action_variable_sale_schedule( $variations : array , $data : array ) : mixed
Parameters
$variations : array

List of variations.

$data : array

Data to set.

Tags
used-by

bulk_edit_variations

Return values
mixed

variation_bulk_action_variable_regular_price_increase()

Bulk action - Increase Regular Prices.

private static variation_bulk_action_variable_regular_price_increase( $variations : array , $data : array ) : mixed
Parameters
$variations : array

List of variations.

$data : array

Data to set.

Tags
used-by

bulk_edit_variations

Return values
mixed

variation_bulk_action_variable_regular_price_decrease()

Bulk action - Decrease Regular Prices.

private static variation_bulk_action_variable_regular_price_decrease( $variations : array , $data : array ) : mixed
Parameters
$variations : array

List of variations.

$data : array

Data to set.

Tags
used-by

bulk_edit_variations

Return values
mixed

variation_bulk_action_variable_sale_price_increase()

Bulk action - Increase Sale Prices.

private static variation_bulk_action_variable_sale_price_increase( $variations : array , $data : array ) : mixed
Parameters
$variations : array

List of variations.

$data : array

Data to set.

Tags
used-by

bulk_edit_variations

Return values
mixed

variation_bulk_action_variable_sale_price_decrease()

Bulk action - Decrease Sale Prices.

private static variation_bulk_action_variable_sale_price_decrease( $variations : array , $data : array ) : mixed
Parameters
$variations : array

List of variations.

$data : array

Data to set.

Tags
used-by

bulk_edit_variations

Return values
mixed

variation_bulk_adjust_price()

Bulk action - Set Price.

private static variation_bulk_adjust_price( $variations : array , $field : string , $operator : string , $value : string ) : mixed
Parameters
$variations : array

List of variations.

$field : string

price being adjusted _regular_price or _sale_price.

$operator : string
  • or -.
$value : string

Price or Percent.

Tags
used-by

bulk_edit_variations

Return values
mixed

variation_bulk_set()

Bulk set convenience function.

private static variation_bulk_set( $variations : array , $field : string , $value : string ) : mixed
Parameters
$variations : array

List of variations.

$field : string

Field to set.

$value : string

to set.

Return values
mixed

variation_bulk_toggle()

Bulk toggle convenience function.

private static variation_bulk_toggle( $variations : array , $field : string ) : mixed
Parameters
$variations : array

List of variations.

$field : string

Field to toggle.

Return values
mixed

bulk_edit_variations()

Bulk edit variations via AJAX.

public static bulk_edit_variations( ) : mixed
Tags
uses
uses
uses
uses
uses
uses
uses
uses
uses
uses
uses
uses
uses
uses
uses
uses
uses
uses
uses
uses
uses
Return values
mixed

tax_rates_save_changes()

Handle submissions from assets/js/settings-views-html-settings-tax.js Backbone model.

public static tax_rates_save_changes( ) : mixed
Return values
mixed

shipping_zones_save_changes()

Handle submissions from assets/js/wc-shipping-zones.js Backbone model.

public static shipping_zones_save_changes( ) : mixed
Return values
mixed

shipping_zone_add_method()

Handle submissions from assets/js/wc-shipping-zone-methods.js Backbone model.

public static shipping_zone_add_method( ) : mixed
Return values
mixed

shipping_zone_methods_save_changes()

Handle submissions from assets/js/wc-shipping-zone-methods.js Backbone model.

public static shipping_zone_methods_save_changes( ) : mixed
Return values
mixed

shipping_zone_methods_save_settings()

Save method settings

public static shipping_zone_methods_save_settings( ) : mixed
Return values
mixed

shipping_classes_save_changes()

Handle submissions from assets/js/wc-shipping-classes.js Backbone model.

public static shipping_classes_save_changes( ) : mixed
Return values
mixed

toggle_gateway_enabled()

Toggle payment gateway on or off via AJAX.

public static toggle_gateway_enabled( ) : mixed
Tags
since
Return values
mixed
Back to the top