Article Category

Useful Core Functions

These core functions can be useful for customizing or extending the use of CoCart to your needs.

These core functions can be useful for customizing or extending the use of CoCart to your needs.

The following useful functions are found in includes/cocart-rest-functions.php

cocart_allowed_image_mime_types()

Returns image mime types users are allowed to upload via the API.

cocart_allowed_image_mime_types();

cocart_upload_dir( $pathdata )

CoCart upload directory.

 cocart_upload_dir( $pathdata );

cocart_upload_file( $file )

Upload a file.

cocart_upload_file( $file );

cocart_upload_image_from_url( $image_url )

Upload image from URL.

cocart_upload_image_from_url( $image_url );

cocart_set_uploaded_image_as_attachment( $upload, $id = 0 )

Set uploaded image as attachment.

cocart_set_uploaded_image_as_attachment( $upload, $id = 0 );

cocart_price_no_html( $price, $args = array() )

Format the price with a currency symbol without HTML wrappers.

Developer Note: Forked wc_price() function and altered to remove HTML wrappers for the use of the REST API.

cocart_price_no_html( $price, $args = array() );

cocart_add_to_cart_message( $products, $show_qty = false, $return = false )

Add to cart messages.

Developer Note: Forked wc_add_to_cart_message() function and altered to remove HTML context for the use of the REST API returning clean notices once products have been added to cart.

cocart_add_to_cart_message( $products, $show_qty = false, $return = false );

cocart_prepare_money_response( $amount, $decimals = 2, $rounding_mode = PHP_ROUND_HALF_UP )

Convert monetary values from WooCommerce to string based integers, using the smallest unit of a currency.

cocart_prepare_money_response( $amount, $decimals = 2, $rounding_mode = PHP_ROUND_HALF_UP )

cocart_get_store_currency()

Prepares a list of store currency data to return in responses.

cocart_get_store_currency()

Was this helpful to you?