wc_string_to_bool( string|bool $string )
Converts a string (e.g. ‘yes’ or ‘no’) to a bool.
Description #Description
Parameters #Parameters
- $string
-
(Required) String to convert. If a bool is passed it will be returned as-is.
Return #Return
(bool)
Source #Source
File: includes/wc-formatting-functions.php
function wc_string_to_bool( $string ) { return is_bool( $string ) ? $string : ( 'yes' === strtolower( $string ) || 1 === $string || 'true' === strtolower( $string ) || '1' === $string ); }
Changelog #Changelog
Version | Description |
---|---|
3.0.0 | Introduced. |
Related #Related
Used By #Used By
Used By | Description |
---|---|
packages/woocommerce-blocks/src/Domain/Services/GoogleAnalytics.php: GoogleAnalytics::enqueue_scripts() |
Enqueue the Google Tag Manager script if prerequisites are met. |
includes/class-wc-cart-fees.php: WC_Cart_Fees::add_fee() |
Add a fee. Fee IDs must be unique. |
includes/wc-formatting-functions.php: wc_bool_to_string() |
Converts a bool to a ‘yes’ or ‘no’. |
includes/admin/settings/class-wc-settings-payment-gateways.php: WC_Settings_Payment_Gateways::output() |
Output the settings. |
includes/admin/settings/class-wc-settings-payment-gateways.php: WC_Settings_Payment_Gateways::payment_gateways_setting() |
Output payment gateway settings. |
includes/admin/importers/mappings/shopify.php: wc_importer_shopify_expand_data() |
Expand special Shopify columns to WC format. |
includes/admin/list-tables/class-wc-admin-list-table-orders.php: WC_Admin_List_Table_Orders::define_bulk_actions() |
Define bulk actions. |
includes/class-wc-shortcodes.php: WC_Shortcodes::product_add_to_cart() |
Display a single product price + cart button. |
includes/class-wc-shortcodes.php: WC_Shortcodes::products() |
List multiple products shortcode. |
includes/import/class-wc-product-csv-importer.php: WC_Product_CSV_Importer::expand_data() |
Expand special and internal data into the correct formats for the product CRUD. |
includes/import/class-wc-product-csv-importer.php: WC_Product_CSV_Importer::parse_published_field() |
Parse the published field. 1 is published, 0 is private, -1 is draft. |
includes/import/class-wc-product-csv-importer.php: WC_Product_CSV_Importer::parse_tax_status_field() |
Parse the tax status field. |
includes/class-wc-frontend-scripts.php: WC_Frontend_Scripts::load_scripts() |
Register/queue frontend scripts. |
includes/class-wc-ajax.php: WC_AJAX::toggle_gateway_enabled() |
Toggle payment gateway on or off via AJAX. |
includes/class-wc-ajax.php: WC_AJAX::update_order_review() |
AJAX update order review on checkout. |
includes/data-stores/class-wc-order-refund-data-store-cpt.php: WC_Order_Refund_Data_Store_CPT::read_order_data() |
Read refund data. Can be overridden by child classes to load other props. |
includes/data-stores/class-wc-order-data-store-cpt.php: WC_Order_Data_Store_CPT::get_stock_reduced() |
Gets information about whether stock was reduced. |
includes/data-stores/class-wc-order-data-store-cpt.php: WC_Order_Data_Store_CPT::get_download_permissions_granted() |
Gets information about whether permissions were generated yet. |
includes/data-stores/class-wc-order-data-store-cpt.php: WC_Order_Data_Store_CPT::get_recorded_sales() |
Gets information about whether sales were recorded. |
includes/data-stores/class-wc-order-data-store-cpt.php: WC_Order_Data_Store_CPT::get_recorded_coupon_usage_counts() |
Gets information about whether coupon counts were updated. |
includes/class-wc-customer.php: WC_Customer::set_is_vat_exempt() |
Set if customer has tax exemption. |
includes/class-wc-customer.php: WC_Customer::set_calculated_shipping() |
Calculated shipping? |
includes/class-wc-product-attribute.php: WC_Product_Attribute::set_visible() |
Set if visible. |
includes/class-wc-product-attribute.php: WC_Product_Attribute::set_variation() |
Set if variation. |
includes/wc-stock-functions.php: wc_get_held_stock_quantity() |
See how much stock is being held in pending orders. |
includes/wc-stock-functions.php: wc_reserve_stock_for_order() |
Hold stock for an order. |
includes/wc-stock-functions.php: wc_release_stock_for_order() |
Release held stock for an order. |
includes/abstracts/abstract-wc-product.php: WC_Product::set_downloadable() |
Set if the product is downloadable. |
includes/abstracts/abstract-wc-product.php: WC_Product::set_virtual() |
Set if the product is virtual. |
includes/abstracts/abstract-wc-product.php: WC_Product::set_reviews_allowed() |
Set if reviews is allowed. |
includes/abstracts/abstract-wc-product.php: WC_Product::set_sold_individually() |
Set if should be sold individually. |
includes/abstracts/abstract-wc-product.php: WC_Product::set_manage_stock() |
Set if product manage stock. |
includes/abstracts/abstract-wc-product.php: WC_Product::set_featured() |
Set if the product is featured. |
includes/class-wc-checkout.php: WC_Checkout::__set() |
Sets the legacy public variables for backwards compatibility. |
includes/export/class-wc-product-csv-exporter.php: WC_Product_CSV_Exporter::get_column_value_backorders() |
Get backorders. |
includes/class-wc-privacy-erasers.php: WC_Privacy_Erasers::order_data_eraser() |
Finds and erases data which could be used to identify a person from WooCommerce data assocated with an email address. |
includes/class-wc-privacy-erasers.php: WC_Privacy_Erasers::download_data_eraser() |
Finds and removes customer download logs by email address. |
includes/class-wc-product-variation.php: WC_Product_Variation::get_manage_stock() |
Return if product manage stock. |
includes/class-wc-coupon.php: WC_Coupon::read_manual_coupon() |
Developers can programmatically return coupons. This function will read those values into our WC_Coupon class. |
includes/shortcodes/class-wc-shortcode-products.php: WC_Shortcode_Products::get_query_results() |
Run the query and return an array of data, including queried ids and pagination information. |
includes/shortcodes/class-wc-shortcode-products.php: WC_Shortcode_Products::product_loop() |
Loop over found products. |
includes/shortcodes/class-wc-shortcode-products.php: WC_Shortcode_Products::parse_query_args() |
Parse query args. |
packages/woocommerce-blocks/src/BlockTypes/ProductCategories.php: ProductCategories::get_categories() |
Get categories (terms) from the db. |
includes/rest-api/Controllers/Version2/class-wc-rest-product-variations-v2-controller.php: WC_REST_Product_Variations_V2_Controller::prepare_object_for_database() |
Prepare a single variation for create or update. |