This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Hide the Bundle When a product is Out of Stock | |
add_filter( 'woocommerce_product_is_visible', 'hide_bundle_when_required_product_is_out_of_stock', 10, 2 ); | |
function hide_bundle_when_required_product_is_out_of_stock( $visible, $product_id ) { | |
$product = wc_get_product( $product_id ); | |
// Check if the product is a bundle | |
if ( $product && $product->is_type( 'bundle' ) ) { | |
$bundled_items = $product->get_bundled_items(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Inside AutomateWoo, use the variable: {custom_function.aw_get_gift_card_code} to include the gift card code in the email. | |
# The gift card codes are stored as order item meta data. | |
function aw_get_gift_card_code( $workflow ) { | |
$order = $workflow->data_layer()->get_order(); | |
foreach ( $order->get_items() as $item ) { | |
if ( $item->get_product()->is_type( 'gift-card' ) ) { | |
$gift_card_code = $item->get_meta( '_wc_gc_giftcard_code', true ); | |
if ( ! empty( $gift_card_code ) ) { | |
return $gift_card_code; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'woocommerce_email_classes', function( $emails ) { | |
if ( isset( $emails['WC_GC_Email_Gift_Card_Received'] ) ) { | |
unset( $emails['WC_GC_Email_Gift_Card_Received'] ); | |
} | |
return $emails; | |
}, 20 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'woocommerce_states', 'dw_woocommerce_states' ); | |
function dw_woocommerce_states( $states ) { | |
$states['KW'] = array( | |
'KWQ' => __('Dasmān','porto'), | |
'KWA' => __('Sharq','porto'), | |
'KWZ' => __('Mirgāb','porto'), | |
'KWW' => __('Jibla','porto'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Hook into the subscription creation process | |
add_action( 'woocommerce_checkout_subscription_created', 'set_gifted_subscription_to_manual_renewal', 10, 2 ); | |
function set_gifted_subscription_to_manual_renewal( $subscription, $order ) { | |
// Check if the subscription is gifted using the gifting plugin's functionality | |
if ( class_exists( 'WCS_Gifting' ) && WCS_Gifting::is_gifted_subscription( $subscription ) ) { | |
// Set the subscription to manual renewal | |
$subscription->set_requires_manual_renewal( true ); | |
// Cancel any scheduled renewal actions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('woocommerce_calculated_total', 'exclude_tax_from_deposits', 10, 2); | |
function exclude_tax_from_deposits($total, $cart) { | |
if (class_exists('WC_Deposits_Cart_Manager') && WC_Deposits_Cart_Manager::is_deposit_enabled_for_cart()) { | |
$total -= WC()->cart->get_taxes_total(); // Exclude taxes from deposit | |
} | |
return $total; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'woocommerce_subscription_price_string', 'change_subscription_text', 10, 2 ); | |
function change_subscription_text( $subscription_string, $subscription_details ) { | |
if ( $subscription_details['subscription_period'] === 'month' ) { | |
$subscription_string = str_replace( 'Monthly Subscription', '30 Day Subscription', $subscription_string ); | |
} | |
return $subscription_string; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('woocommerce_scheduled_subscription_payment', 'recalculate_taxes_before_payment', 10, 1); | |
function recalculate_taxes_before_payment($subscription_id) { | |
$subscription = wcs_get_subscription($subscription_id); | |
if ($subscription) { | |
foreach ($subscription->get_related_orders() as $renewal_order_id) { | |
$renewal_order = wc_get_order($renewal_order_id); | |
if ($renewal_order && 'pending' === $renewal_order->get_status()) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('woocommerce_subscription_status_cancelled', 'restock_inventory_on_subscripadd_action('woocommerce_subscription_status_cancelled', 'adjust_inventory_on_subscription_cancel', 10, 1); | |
function adjust_inventory_on_subscription_cancel($subscription) { | |
if (!$subscription) return; | |
foreach ($subscription->get_items() as $item) { | |
$product = $item->get_product(); | |
if ($product && $product->managing_stock()) { | |
$current_stock = $product->get_stock_quantity(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'woocommerce_check_cart_items', 'mandatory_global_coupon_code' ); | |
function mandatory_global_coupon_code() { | |
$coupon_code = 'summer2'; // The required coupon code | |
// Check if the required coupon is applied | |
$coupon_applied = in_array( strtolower( $coupon_code ), WC()->cart->get_applied_coupons() ); | |
// If the coupon is not applied, prevent checkout | |
if ( ! $coupon_applied ) { |
NewerOlder