Skip to content

Instantly share code, notes, and snippets.

@IliaDi
IliaDi / wc_csp_check_shipping_zones.php
Created January 25, 2023 18:03
Display a notice on the settings page if there are no Shipping Zones yet
function wc_csp_check_shipping_zones(){
global $current_screen;
$screen = get_current_screen();
$screen_id = $screen ? $screen->id : '';
if ( $screen_id == 'woocommerce_page_wc-settings'){
$zones = WC_Shipping_Zones::get_zones();
if ( empty($zones) ) {
echo '<div class="notice notice-warning is-dismissible">
<p>It appears that your store does not have any Shipping Zones yet. Before setting up Shipping Methods Restrictions, it will be necessary to create Shipping Zones with all available Shipping Methods. <a href="https://docs.woocommerce.com/document/setting-up-shipping-zones/">Learn more here</a>
@IliaDi
IliaDi / wc_pb_display_bundles.php
Last active March 26, 2025 08:47
display bundles that the currently viewed product is included in
<?php
add_action('woocommerce_after_add_to_cart_form', 'wc_pb_display_bundles');
function wc_pb_display_bundles(){
global $product;
$product_id = $product->get_id();
$bundle_ids = wc_pb_get_bundled_product_map( $product_id, false );
if (!empty( $bundle_ids)){
$bundle_ids_list = implode( ",", $bundle_ids );