WooCommerce Show checkout fields based on product category











up vote
1
down vote

favorite












I have added below code to show currency switcher dropdown on the WooCommerce checkout page which is working fine, but I don’t want to show currency switcher field if anyone has added product from "Games" category and use only default store currency



Code 1



add_action('woocommerce_before_checkout_billing_form', 'wps_add_select_checkout_field');
function wps_add_select_checkout_field( $checkout ) {
echo '<label for="payment_option" class="payment_option">'.__('Preferred currency').'</label>';
echo '<div class="own">', do_shortcode('[woocs]'), '</div>';
return $checkout;
}

//* Process the checkout
add_action('woocommerce_checkout_process', 'wps_select_checkout_field_process');
function wps_select_checkout_field_process() {
global $woocommerce;
// Check if set, if its not set add an error.
if ($_POST['payopt'] == "blank")
wc_add_notice( '<strong>Please select a currency</strong>', 'error' );
}


Based on this answer thread: Checking cart items for a product category in Woocommerce
I have tried below code and I think something is missing, If I am using below code it's not showing currency switcher at all even if product is from "Games" or other categories.



Code 2



add_action('woocommerce_before_cart', 'check_product_category_in_cart');
function check_product_category_in_cart() {
// Here set your product categories in the array (can be IDs, slugs or names)
$categories = array('games');
$found = false; // Initializing

// Loop through cart items
foreach ( WC()->cart->get_cart() as $cart_item ) {
// If product categories is found
if ( !has_term( $categories, 'product_cat', $cart_item['product_id'] ) ) {
$found = true; // Set to true
break; // Stop the loop
}
}

// If any defined product category is found, run below code
if ( $found ) {
add_action('woocommerce_before_checkout_billing_form', 'wps_add_select_checkout_field');
function wps_add_select_checkout_field( $checkout ) {
echo '<label for="payment_option" class="payment_option">'.__('Preferred currency').'</label>';
echo '<div class="own">', do_shortcode('[woocs]'), '</div>';
return $checkout;
}
//* Process the checkout
add_action('woocommerce_checkout_process', 'wps_select_checkout_field_process');
function wps_select_checkout_field_process() {
global $woocommerce;
// Check if set, if its not set add an error.
if ($_POST['payopt'] == "blank")
wc_add_notice( '<strong>Please select a currency</strong>', 'error' );
}
}
}


Do you have any other suggestion for the same? Where I can add currency switcher on checkout page based on cart product category. Code 1 is working fine on the checkout page but I don't want to run that code if product category is games.










share|improve this question
























  • Yes I have answered and it should works, even if I can't test it as the shortcode [woocs] will not output a select field for me on my test server.
    – LoicTheAztec
    Nov 12 at 11:52

















up vote
1
down vote

favorite












I have added below code to show currency switcher dropdown on the WooCommerce checkout page which is working fine, but I don’t want to show currency switcher field if anyone has added product from "Games" category and use only default store currency



Code 1



add_action('woocommerce_before_checkout_billing_form', 'wps_add_select_checkout_field');
function wps_add_select_checkout_field( $checkout ) {
echo '<label for="payment_option" class="payment_option">'.__('Preferred currency').'</label>';
echo '<div class="own">', do_shortcode('[woocs]'), '</div>';
return $checkout;
}

//* Process the checkout
add_action('woocommerce_checkout_process', 'wps_select_checkout_field_process');
function wps_select_checkout_field_process() {
global $woocommerce;
// Check if set, if its not set add an error.
if ($_POST['payopt'] == "blank")
wc_add_notice( '<strong>Please select a currency</strong>', 'error' );
}


Based on this answer thread: Checking cart items for a product category in Woocommerce
I have tried below code and I think something is missing, If I am using below code it's not showing currency switcher at all even if product is from "Games" or other categories.



Code 2



add_action('woocommerce_before_cart', 'check_product_category_in_cart');
function check_product_category_in_cart() {
// Here set your product categories in the array (can be IDs, slugs or names)
$categories = array('games');
$found = false; // Initializing

// Loop through cart items
foreach ( WC()->cart->get_cart() as $cart_item ) {
// If product categories is found
if ( !has_term( $categories, 'product_cat', $cart_item['product_id'] ) ) {
$found = true; // Set to true
break; // Stop the loop
}
}

// If any defined product category is found, run below code
if ( $found ) {
add_action('woocommerce_before_checkout_billing_form', 'wps_add_select_checkout_field');
function wps_add_select_checkout_field( $checkout ) {
echo '<label for="payment_option" class="payment_option">'.__('Preferred currency').'</label>';
echo '<div class="own">', do_shortcode('[woocs]'), '</div>';
return $checkout;
}
//* Process the checkout
add_action('woocommerce_checkout_process', 'wps_select_checkout_field_process');
function wps_select_checkout_field_process() {
global $woocommerce;
// Check if set, if its not set add an error.
if ($_POST['payopt'] == "blank")
wc_add_notice( '<strong>Please select a currency</strong>', 'error' );
}
}
}


Do you have any other suggestion for the same? Where I can add currency switcher on checkout page based on cart product category. Code 1 is working fine on the checkout page but I don't want to run that code if product category is games.










share|improve this question
























  • Yes I have answered and it should works, even if I can't test it as the shortcode [woocs] will not output a select field for me on my test server.
    – LoicTheAztec
    Nov 12 at 11:52















up vote
1
down vote

favorite









up vote
1
down vote

favorite











I have added below code to show currency switcher dropdown on the WooCommerce checkout page which is working fine, but I don’t want to show currency switcher field if anyone has added product from "Games" category and use only default store currency



Code 1



add_action('woocommerce_before_checkout_billing_form', 'wps_add_select_checkout_field');
function wps_add_select_checkout_field( $checkout ) {
echo '<label for="payment_option" class="payment_option">'.__('Preferred currency').'</label>';
echo '<div class="own">', do_shortcode('[woocs]'), '</div>';
return $checkout;
}

//* Process the checkout
add_action('woocommerce_checkout_process', 'wps_select_checkout_field_process');
function wps_select_checkout_field_process() {
global $woocommerce;
// Check if set, if its not set add an error.
if ($_POST['payopt'] == "blank")
wc_add_notice( '<strong>Please select a currency</strong>', 'error' );
}


Based on this answer thread: Checking cart items for a product category in Woocommerce
I have tried below code and I think something is missing, If I am using below code it's not showing currency switcher at all even if product is from "Games" or other categories.



Code 2



add_action('woocommerce_before_cart', 'check_product_category_in_cart');
function check_product_category_in_cart() {
// Here set your product categories in the array (can be IDs, slugs or names)
$categories = array('games');
$found = false; // Initializing

// Loop through cart items
foreach ( WC()->cart->get_cart() as $cart_item ) {
// If product categories is found
if ( !has_term( $categories, 'product_cat', $cart_item['product_id'] ) ) {
$found = true; // Set to true
break; // Stop the loop
}
}

// If any defined product category is found, run below code
if ( $found ) {
add_action('woocommerce_before_checkout_billing_form', 'wps_add_select_checkout_field');
function wps_add_select_checkout_field( $checkout ) {
echo '<label for="payment_option" class="payment_option">'.__('Preferred currency').'</label>';
echo '<div class="own">', do_shortcode('[woocs]'), '</div>';
return $checkout;
}
//* Process the checkout
add_action('woocommerce_checkout_process', 'wps_select_checkout_field_process');
function wps_select_checkout_field_process() {
global $woocommerce;
// Check if set, if its not set add an error.
if ($_POST['payopt'] == "blank")
wc_add_notice( '<strong>Please select a currency</strong>', 'error' );
}
}
}


Do you have any other suggestion for the same? Where I can add currency switcher on checkout page based on cart product category. Code 1 is working fine on the checkout page but I don't want to run that code if product category is games.










share|improve this question















I have added below code to show currency switcher dropdown on the WooCommerce checkout page which is working fine, but I don’t want to show currency switcher field if anyone has added product from "Games" category and use only default store currency



Code 1



add_action('woocommerce_before_checkout_billing_form', 'wps_add_select_checkout_field');
function wps_add_select_checkout_field( $checkout ) {
echo '<label for="payment_option" class="payment_option">'.__('Preferred currency').'</label>';
echo '<div class="own">', do_shortcode('[woocs]'), '</div>';
return $checkout;
}

//* Process the checkout
add_action('woocommerce_checkout_process', 'wps_select_checkout_field_process');
function wps_select_checkout_field_process() {
global $woocommerce;
// Check if set, if its not set add an error.
if ($_POST['payopt'] == "blank")
wc_add_notice( '<strong>Please select a currency</strong>', 'error' );
}


Based on this answer thread: Checking cart items for a product category in Woocommerce
I have tried below code and I think something is missing, If I am using below code it's not showing currency switcher at all even if product is from "Games" or other categories.



Code 2



add_action('woocommerce_before_cart', 'check_product_category_in_cart');
function check_product_category_in_cart() {
// Here set your product categories in the array (can be IDs, slugs or names)
$categories = array('games');
$found = false; // Initializing

// Loop through cart items
foreach ( WC()->cart->get_cart() as $cart_item ) {
// If product categories is found
if ( !has_term( $categories, 'product_cat', $cart_item['product_id'] ) ) {
$found = true; // Set to true
break; // Stop the loop
}
}

// If any defined product category is found, run below code
if ( $found ) {
add_action('woocommerce_before_checkout_billing_form', 'wps_add_select_checkout_field');
function wps_add_select_checkout_field( $checkout ) {
echo '<label for="payment_option" class="payment_option">'.__('Preferred currency').'</label>';
echo '<div class="own">', do_shortcode('[woocs]'), '</div>';
return $checkout;
}
//* Process the checkout
add_action('woocommerce_checkout_process', 'wps_select_checkout_field_process');
function wps_select_checkout_field_process() {
global $woocommerce;
// Check if set, if its not set add an error.
if ($_POST['payopt'] == "blank")
wc_add_notice( '<strong>Please select a currency</strong>', 'error' );
}
}
}


Do you have any other suggestion for the same? Where I can add currency switcher on checkout page based on cart product category. Code 1 is working fine on the checkout page but I don't want to run that code if product category is games.







php wordpress woocommerce






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 24 at 18:14









marc_s

568k12810991249




568k12810991249










asked Nov 12 at 6:37









Group Of Oceninfo

130115




130115












  • Yes I have answered and it should works, even if I can't test it as the shortcode [woocs] will not output a select field for me on my test server.
    – LoicTheAztec
    Nov 12 at 11:52




















  • Yes I have answered and it should works, even if I can't test it as the shortcode [woocs] will not output a select field for me on my test server.
    – LoicTheAztec
    Nov 12 at 11:52


















Yes I have answered and it should works, even if I can't test it as the shortcode [woocs] will not output a select field for me on my test server.
– LoicTheAztec
Nov 12 at 11:52






Yes I have answered and it should works, even if I can't test it as the shortcode [woocs] will not output a select field for me on my test server.
– LoicTheAztec
Nov 12 at 11:52














1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










You are not using the correct hook as woocommerce_before_cart action hook is only triggered in cart page, but not in checkout and it can't work this way. Instead try to use the following:



// Utility function that checks if at least a cart items remains to a product category
function has_product_category_in_cart( $product_category ) {
// Loop through cart items
foreach ( WC()->cart->get_cart() as $cart_item ) {
// If any product category is found in cart items
if ( has_term( $product_category, 'product_cat', $cart_item['product_id'] ) ) {
return true;
}
}
return false;
}

// Add a custom select field in checkout
add_action('woocommerce_before_checkout_billing_form', 'add_custom_checkout_select_field');
function add_custom_checkout_select_field( $checkout ) {
// Here set in the function your product category term ID, slugs, names or array
if ( ! has_product_category_in_cart( 'games' ) && shortcode_exists( 'woocs' ) ) {
echo '<label for="payment_option" class="payment_option">'.__('Preferred currency').'</label>';
echo '<div class="own">' . do_shortcode('[woocs]') . '</div>';
}
}

// Custom Checkout fields validation
add_action('woocommerce_checkout_process', 'custom_checkout_select_field_validation');
function custom_checkout_select_field_validation() {
if ( isset($_POST['payopt']) && empty($_POST['payopt']) )
wc_add_notice( '<strong>Please select a currency</strong>', 'error' );
}


Code goes in function.php file of your active child theme (active theme). Untested but it should works.






share|improve this answer























  • Thanks for the code, I have tested it, it's not showing a currency switcher field at all, Even if the product is not from "Games" category. I am using WooCommerce Currency Switcher By realmag777 plugin.
    – Group Of Oceninfo
    Nov 12 at 12:13












  • @GroupOfOceninfo Sorry there was a little mistake in my code… in shortcode_exists( 'payopt' ) replaced by shortcode_exists( 'woocs' ) … try it again please.
    – LoicTheAztec
    Nov 12 at 12:29






  • 1




    Thanks for the update, it works but when someone is adding multiple category products it won't work, it'll show the fields. i.e. if someone has product from non-game + game then it's showing the currency switcher which I would like to ignore.
    – Group Of Oceninfo
    Nov 12 at 12:33












  • @GroupOfOceninfo I have accepted your edit (as it doesn't change the code main idea and philosophy)
    – LoicTheAztec
    Nov 13 at 13:56













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53256999%2fwoocommerce-show-checkout-fields-based-on-product-category%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










You are not using the correct hook as woocommerce_before_cart action hook is only triggered in cart page, but not in checkout and it can't work this way. Instead try to use the following:



// Utility function that checks if at least a cart items remains to a product category
function has_product_category_in_cart( $product_category ) {
// Loop through cart items
foreach ( WC()->cart->get_cart() as $cart_item ) {
// If any product category is found in cart items
if ( has_term( $product_category, 'product_cat', $cart_item['product_id'] ) ) {
return true;
}
}
return false;
}

// Add a custom select field in checkout
add_action('woocommerce_before_checkout_billing_form', 'add_custom_checkout_select_field');
function add_custom_checkout_select_field( $checkout ) {
// Here set in the function your product category term ID, slugs, names or array
if ( ! has_product_category_in_cart( 'games' ) && shortcode_exists( 'woocs' ) ) {
echo '<label for="payment_option" class="payment_option">'.__('Preferred currency').'</label>';
echo '<div class="own">' . do_shortcode('[woocs]') . '</div>';
}
}

// Custom Checkout fields validation
add_action('woocommerce_checkout_process', 'custom_checkout_select_field_validation');
function custom_checkout_select_field_validation() {
if ( isset($_POST['payopt']) && empty($_POST['payopt']) )
wc_add_notice( '<strong>Please select a currency</strong>', 'error' );
}


Code goes in function.php file of your active child theme (active theme). Untested but it should works.






share|improve this answer























  • Thanks for the code, I have tested it, it's not showing a currency switcher field at all, Even if the product is not from "Games" category. I am using WooCommerce Currency Switcher By realmag777 plugin.
    – Group Of Oceninfo
    Nov 12 at 12:13












  • @GroupOfOceninfo Sorry there was a little mistake in my code… in shortcode_exists( 'payopt' ) replaced by shortcode_exists( 'woocs' ) … try it again please.
    – LoicTheAztec
    Nov 12 at 12:29






  • 1




    Thanks for the update, it works but when someone is adding multiple category products it won't work, it'll show the fields. i.e. if someone has product from non-game + game then it's showing the currency switcher which I would like to ignore.
    – Group Of Oceninfo
    Nov 12 at 12:33












  • @GroupOfOceninfo I have accepted your edit (as it doesn't change the code main idea and philosophy)
    – LoicTheAztec
    Nov 13 at 13:56

















up vote
1
down vote



accepted










You are not using the correct hook as woocommerce_before_cart action hook is only triggered in cart page, but not in checkout and it can't work this way. Instead try to use the following:



// Utility function that checks if at least a cart items remains to a product category
function has_product_category_in_cart( $product_category ) {
// Loop through cart items
foreach ( WC()->cart->get_cart() as $cart_item ) {
// If any product category is found in cart items
if ( has_term( $product_category, 'product_cat', $cart_item['product_id'] ) ) {
return true;
}
}
return false;
}

// Add a custom select field in checkout
add_action('woocommerce_before_checkout_billing_form', 'add_custom_checkout_select_field');
function add_custom_checkout_select_field( $checkout ) {
// Here set in the function your product category term ID, slugs, names or array
if ( ! has_product_category_in_cart( 'games' ) && shortcode_exists( 'woocs' ) ) {
echo '<label for="payment_option" class="payment_option">'.__('Preferred currency').'</label>';
echo '<div class="own">' . do_shortcode('[woocs]') . '</div>';
}
}

// Custom Checkout fields validation
add_action('woocommerce_checkout_process', 'custom_checkout_select_field_validation');
function custom_checkout_select_field_validation() {
if ( isset($_POST['payopt']) && empty($_POST['payopt']) )
wc_add_notice( '<strong>Please select a currency</strong>', 'error' );
}


Code goes in function.php file of your active child theme (active theme). Untested but it should works.






share|improve this answer























  • Thanks for the code, I have tested it, it's not showing a currency switcher field at all, Even if the product is not from "Games" category. I am using WooCommerce Currency Switcher By realmag777 plugin.
    – Group Of Oceninfo
    Nov 12 at 12:13












  • @GroupOfOceninfo Sorry there was a little mistake in my code… in shortcode_exists( 'payopt' ) replaced by shortcode_exists( 'woocs' ) … try it again please.
    – LoicTheAztec
    Nov 12 at 12:29






  • 1




    Thanks for the update, it works but when someone is adding multiple category products it won't work, it'll show the fields. i.e. if someone has product from non-game + game then it's showing the currency switcher which I would like to ignore.
    – Group Of Oceninfo
    Nov 12 at 12:33












  • @GroupOfOceninfo I have accepted your edit (as it doesn't change the code main idea and philosophy)
    – LoicTheAztec
    Nov 13 at 13:56















up vote
1
down vote



accepted







up vote
1
down vote



accepted






You are not using the correct hook as woocommerce_before_cart action hook is only triggered in cart page, but not in checkout and it can't work this way. Instead try to use the following:



// Utility function that checks if at least a cart items remains to a product category
function has_product_category_in_cart( $product_category ) {
// Loop through cart items
foreach ( WC()->cart->get_cart() as $cart_item ) {
// If any product category is found in cart items
if ( has_term( $product_category, 'product_cat', $cart_item['product_id'] ) ) {
return true;
}
}
return false;
}

// Add a custom select field in checkout
add_action('woocommerce_before_checkout_billing_form', 'add_custom_checkout_select_field');
function add_custom_checkout_select_field( $checkout ) {
// Here set in the function your product category term ID, slugs, names or array
if ( ! has_product_category_in_cart( 'games' ) && shortcode_exists( 'woocs' ) ) {
echo '<label for="payment_option" class="payment_option">'.__('Preferred currency').'</label>';
echo '<div class="own">' . do_shortcode('[woocs]') . '</div>';
}
}

// Custom Checkout fields validation
add_action('woocommerce_checkout_process', 'custom_checkout_select_field_validation');
function custom_checkout_select_field_validation() {
if ( isset($_POST['payopt']) && empty($_POST['payopt']) )
wc_add_notice( '<strong>Please select a currency</strong>', 'error' );
}


Code goes in function.php file of your active child theme (active theme). Untested but it should works.






share|improve this answer














You are not using the correct hook as woocommerce_before_cart action hook is only triggered in cart page, but not in checkout and it can't work this way. Instead try to use the following:



// Utility function that checks if at least a cart items remains to a product category
function has_product_category_in_cart( $product_category ) {
// Loop through cart items
foreach ( WC()->cart->get_cart() as $cart_item ) {
// If any product category is found in cart items
if ( has_term( $product_category, 'product_cat', $cart_item['product_id'] ) ) {
return true;
}
}
return false;
}

// Add a custom select field in checkout
add_action('woocommerce_before_checkout_billing_form', 'add_custom_checkout_select_field');
function add_custom_checkout_select_field( $checkout ) {
// Here set in the function your product category term ID, slugs, names or array
if ( ! has_product_category_in_cart( 'games' ) && shortcode_exists( 'woocs' ) ) {
echo '<label for="payment_option" class="payment_option">'.__('Preferred currency').'</label>';
echo '<div class="own">' . do_shortcode('[woocs]') . '</div>';
}
}

// Custom Checkout fields validation
add_action('woocommerce_checkout_process', 'custom_checkout_select_field_validation');
function custom_checkout_select_field_validation() {
if ( isset($_POST['payopt']) && empty($_POST['payopt']) )
wc_add_notice( '<strong>Please select a currency</strong>', 'error' );
}


Code goes in function.php file of your active child theme (active theme). Untested but it should works.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 13 at 13:55









Group Of Oceninfo

130115




130115










answered Nov 12 at 11:48









LoicTheAztec

82.8k125993




82.8k125993












  • Thanks for the code, I have tested it, it's not showing a currency switcher field at all, Even if the product is not from "Games" category. I am using WooCommerce Currency Switcher By realmag777 plugin.
    – Group Of Oceninfo
    Nov 12 at 12:13












  • @GroupOfOceninfo Sorry there was a little mistake in my code… in shortcode_exists( 'payopt' ) replaced by shortcode_exists( 'woocs' ) … try it again please.
    – LoicTheAztec
    Nov 12 at 12:29






  • 1




    Thanks for the update, it works but when someone is adding multiple category products it won't work, it'll show the fields. i.e. if someone has product from non-game + game then it's showing the currency switcher which I would like to ignore.
    – Group Of Oceninfo
    Nov 12 at 12:33












  • @GroupOfOceninfo I have accepted your edit (as it doesn't change the code main idea and philosophy)
    – LoicTheAztec
    Nov 13 at 13:56




















  • Thanks for the code, I have tested it, it's not showing a currency switcher field at all, Even if the product is not from "Games" category. I am using WooCommerce Currency Switcher By realmag777 plugin.
    – Group Of Oceninfo
    Nov 12 at 12:13












  • @GroupOfOceninfo Sorry there was a little mistake in my code… in shortcode_exists( 'payopt' ) replaced by shortcode_exists( 'woocs' ) … try it again please.
    – LoicTheAztec
    Nov 12 at 12:29






  • 1




    Thanks for the update, it works but when someone is adding multiple category products it won't work, it'll show the fields. i.e. if someone has product from non-game + game then it's showing the currency switcher which I would like to ignore.
    – Group Of Oceninfo
    Nov 12 at 12:33












  • @GroupOfOceninfo I have accepted your edit (as it doesn't change the code main idea and philosophy)
    – LoicTheAztec
    Nov 13 at 13:56


















Thanks for the code, I have tested it, it's not showing a currency switcher field at all, Even if the product is not from "Games" category. I am using WooCommerce Currency Switcher By realmag777 plugin.
– Group Of Oceninfo
Nov 12 at 12:13






Thanks for the code, I have tested it, it's not showing a currency switcher field at all, Even if the product is not from "Games" category. I am using WooCommerce Currency Switcher By realmag777 plugin.
– Group Of Oceninfo
Nov 12 at 12:13














@GroupOfOceninfo Sorry there was a little mistake in my code… in shortcode_exists( 'payopt' ) replaced by shortcode_exists( 'woocs' ) … try it again please.
– LoicTheAztec
Nov 12 at 12:29




@GroupOfOceninfo Sorry there was a little mistake in my code… in shortcode_exists( 'payopt' ) replaced by shortcode_exists( 'woocs' ) … try it again please.
– LoicTheAztec
Nov 12 at 12:29




1




1




Thanks for the update, it works but when someone is adding multiple category products it won't work, it'll show the fields. i.e. if someone has product from non-game + game then it's showing the currency switcher which I would like to ignore.
– Group Of Oceninfo
Nov 12 at 12:33






Thanks for the update, it works but when someone is adding multiple category products it won't work, it'll show the fields. i.e. if someone has product from non-game + game then it's showing the currency switcher which I would like to ignore.
– Group Of Oceninfo
Nov 12 at 12:33














@GroupOfOceninfo I have accepted your edit (as it doesn't change the code main idea and philosophy)
– LoicTheAztec
Nov 13 at 13:56






@GroupOfOceninfo I have accepted your edit (as it doesn't change the code main idea and philosophy)
– LoicTheAztec
Nov 13 at 13:56




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53256999%2fwoocommerce-show-checkout-fields-based-on-product-category%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Guess what letter conforming each word

Port of Spain

Run scheduled task as local user group (not BUILTIN)