<?php/** * Plugin Name: Custom product support for Price Based on Country * Description: An example plugin to add support for a custom product to PBoC. * Author: Oscar Gare * Author URI: https://www.pricebasedcountry.com/ * Plugin URI: https://www.pricebasedcountry.com/ *//** * Return the custom product type name. */functionmy_custom_product_type_name(){return'custom';}/** * Adds show_custom class to the pricing div. */functionmy_custom_product_data_options(){?><scripttype="text/javascript"> jQuery( document ).ready( function($) {
$( 'div.options_group.wcpbc_pricing' ).addClass( 'show_if_<?phpechoesc_attr(my_custom_product_type_name());?>' );
$( 'input#_downloadable' ).triggerHandler('change'); //call to show_and_hide_panels WooCommerce function
} );
</script><?php}add_action('woocommerce_product_options_general_product_data','my_custom_product_data_options',100);/** * Save the meta data for the custom product. */add_action('woocommerce_process_product_meta_'.my_custom_product_type_name(),array('WCPBC_Admin_Meta_Boxes','process_product_meta'));/** * Add custom product type to the handled product types. * * @param array $types Array of product types. */functionmy_custom_product_types_overriden($types){array_push($types,my_custom_product_type_name());return$types;}add_filter('wc_price_based_country_product_types_overriden','my_custom_product_types_overriden');/** * Add the product type to the list of third party product types to hide the message "Product type not supported" * * @param array $types Array of third party product types. */functionmy_custom_product_third_party_product_types($types){$product_type=my_custom_product_type_name();$types[$product_type]='Product type author name';return$types;}add_filter('wc_price_based_country_third_party_product_types','my_custom_product_third_party_product_types');
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.