Hide dropdown with only 1 variable in Woocommerce












0















I'm using Woocommerce, and I'm looking for a way to automatically hide the dropdown feature when there is only 1 option for that specific variable/variation.



I Tried Hide variable product dropdown that has a unique variation selected by default in Woocommerce



It hides the dropdown feature when only 1 variation is available for that product.



This code seemed to have worked for another guy, but I cannot seem to make it work in my case.



I tried to experiment with the code, but I couldn't seem to make it work.



Any help will definitely be appreciated



Edit:

Currently, what I have are 2 attributes. 1 of them has only 1 variation/option, and the other 1 has 3 variation/option. What do I need to change to the code to make it work for my case?










share|improve this question

























  • What do you mean by "but I cannot seem to make it work now"? Does it show something on your browser for products with only one option? If yes, what is it? For products with more than one variation, do you have your page displayed as expected? Do you have a blank screen?

    – Cedric
    Nov 28 '18 at 20:31











  • You may have only one variation that does not have the default attribute as attribute, but another. (I may update the answer once you provide some more information)

    – Cedric
    Nov 28 '18 at 20:33











  • Sorry but this code still perfectly works… But it requires that unique variation to be selected as default variation (displayed "selected" by default). If not the code doesn't work. This is specified at the beginning of the answer… So please read before saying that it don't work. Additionally if you dont make changes to a stackOverFlow answer code, Just add the link in your question.

    – LoicTheAztec
    Nov 29 '18 at 0:35













  • Hey guys, sorry about that... This is my first time asking a question, but I am very thankful for the help. I did have a look through at the edited thread by @LoicTheAztec, and it did work but only when there is one attribute. Currently, what I have are 2 attributes. 1 of them has only 1 variation/option, and the other 1 has 3 variation/option. I would like to hide the attribute that only has one variation/option, while still showing the 1 attribute that has 3 variation/option. Just want to say sorry again for being confusing/misleading! Thanks again!

    – websiteguy
    Nov 29 '18 at 2:51













  • @websiteguy As the thread title says "1 active default selected variation" … You will need to make your own code based on your specific requirements and variation settings. Anyway a preselected variation is needed and you will need to hide the little "clear" button too (that reset all dropdowns).

    – LoicTheAztec
    Nov 29 '18 at 3:07
















0















I'm using Woocommerce, and I'm looking for a way to automatically hide the dropdown feature when there is only 1 option for that specific variable/variation.



I Tried Hide variable product dropdown that has a unique variation selected by default in Woocommerce



It hides the dropdown feature when only 1 variation is available for that product.



This code seemed to have worked for another guy, but I cannot seem to make it work in my case.



I tried to experiment with the code, but I couldn't seem to make it work.



Any help will definitely be appreciated



Edit:

Currently, what I have are 2 attributes. 1 of them has only 1 variation/option, and the other 1 has 3 variation/option. What do I need to change to the code to make it work for my case?










share|improve this question

























  • What do you mean by "but I cannot seem to make it work now"? Does it show something on your browser for products with only one option? If yes, what is it? For products with more than one variation, do you have your page displayed as expected? Do you have a blank screen?

    – Cedric
    Nov 28 '18 at 20:31











  • You may have only one variation that does not have the default attribute as attribute, but another. (I may update the answer once you provide some more information)

    – Cedric
    Nov 28 '18 at 20:33











  • Sorry but this code still perfectly works… But it requires that unique variation to be selected as default variation (displayed "selected" by default). If not the code doesn't work. This is specified at the beginning of the answer… So please read before saying that it don't work. Additionally if you dont make changes to a stackOverFlow answer code, Just add the link in your question.

    – LoicTheAztec
    Nov 29 '18 at 0:35













  • Hey guys, sorry about that... This is my first time asking a question, but I am very thankful for the help. I did have a look through at the edited thread by @LoicTheAztec, and it did work but only when there is one attribute. Currently, what I have are 2 attributes. 1 of them has only 1 variation/option, and the other 1 has 3 variation/option. I would like to hide the attribute that only has one variation/option, while still showing the 1 attribute that has 3 variation/option. Just want to say sorry again for being confusing/misleading! Thanks again!

    – websiteguy
    Nov 29 '18 at 2:51













  • @websiteguy As the thread title says "1 active default selected variation" … You will need to make your own code based on your specific requirements and variation settings. Anyway a preselected variation is needed and you will need to hide the little "clear" button too (that reset all dropdowns).

    – LoicTheAztec
    Nov 29 '18 at 3:07














0












0








0








I'm using Woocommerce, and I'm looking for a way to automatically hide the dropdown feature when there is only 1 option for that specific variable/variation.



I Tried Hide variable product dropdown that has a unique variation selected by default in Woocommerce



It hides the dropdown feature when only 1 variation is available for that product.



This code seemed to have worked for another guy, but I cannot seem to make it work in my case.



I tried to experiment with the code, but I couldn't seem to make it work.



Any help will definitely be appreciated



Edit:

Currently, what I have are 2 attributes. 1 of them has only 1 variation/option, and the other 1 has 3 variation/option. What do I need to change to the code to make it work for my case?










share|improve this question
















I'm using Woocommerce, and I'm looking for a way to automatically hide the dropdown feature when there is only 1 option for that specific variable/variation.



I Tried Hide variable product dropdown that has a unique variation selected by default in Woocommerce



It hides the dropdown feature when only 1 variation is available for that product.



This code seemed to have worked for another guy, but I cannot seem to make it work in my case.



I tried to experiment with the code, but I couldn't seem to make it work.



Any help will definitely be appreciated



Edit:

Currently, what I have are 2 attributes. 1 of them has only 1 variation/option, and the other 1 has 3 variation/option. What do I need to change to the code to make it work for my case?







php wordpress woocommerce






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 29 '18 at 3:13









LoicTheAztec

94.9k1370109




94.9k1370109










asked Nov 28 '18 at 17:48









websiteguywebsiteguy

1




1













  • What do you mean by "but I cannot seem to make it work now"? Does it show something on your browser for products with only one option? If yes, what is it? For products with more than one variation, do you have your page displayed as expected? Do you have a blank screen?

    – Cedric
    Nov 28 '18 at 20:31











  • You may have only one variation that does not have the default attribute as attribute, but another. (I may update the answer once you provide some more information)

    – Cedric
    Nov 28 '18 at 20:33











  • Sorry but this code still perfectly works… But it requires that unique variation to be selected as default variation (displayed "selected" by default). If not the code doesn't work. This is specified at the beginning of the answer… So please read before saying that it don't work. Additionally if you dont make changes to a stackOverFlow answer code, Just add the link in your question.

    – LoicTheAztec
    Nov 29 '18 at 0:35













  • Hey guys, sorry about that... This is my first time asking a question, but I am very thankful for the help. I did have a look through at the edited thread by @LoicTheAztec, and it did work but only when there is one attribute. Currently, what I have are 2 attributes. 1 of them has only 1 variation/option, and the other 1 has 3 variation/option. I would like to hide the attribute that only has one variation/option, while still showing the 1 attribute that has 3 variation/option. Just want to say sorry again for being confusing/misleading! Thanks again!

    – websiteguy
    Nov 29 '18 at 2:51













  • @websiteguy As the thread title says "1 active default selected variation" … You will need to make your own code based on your specific requirements and variation settings. Anyway a preselected variation is needed and you will need to hide the little "clear" button too (that reset all dropdowns).

    – LoicTheAztec
    Nov 29 '18 at 3:07



















  • What do you mean by "but I cannot seem to make it work now"? Does it show something on your browser for products with only one option? If yes, what is it? For products with more than one variation, do you have your page displayed as expected? Do you have a blank screen?

    – Cedric
    Nov 28 '18 at 20:31











  • You may have only one variation that does not have the default attribute as attribute, but another. (I may update the answer once you provide some more information)

    – Cedric
    Nov 28 '18 at 20:33











  • Sorry but this code still perfectly works… But it requires that unique variation to be selected as default variation (displayed "selected" by default). If not the code doesn't work. This is specified at the beginning of the answer… So please read before saying that it don't work. Additionally if you dont make changes to a stackOverFlow answer code, Just add the link in your question.

    – LoicTheAztec
    Nov 29 '18 at 0:35













  • Hey guys, sorry about that... This is my first time asking a question, but I am very thankful for the help. I did have a look through at the edited thread by @LoicTheAztec, and it did work but only when there is one attribute. Currently, what I have are 2 attributes. 1 of them has only 1 variation/option, and the other 1 has 3 variation/option. I would like to hide the attribute that only has one variation/option, while still showing the 1 attribute that has 3 variation/option. Just want to say sorry again for being confusing/misleading! Thanks again!

    – websiteguy
    Nov 29 '18 at 2:51













  • @websiteguy As the thread title says "1 active default selected variation" … You will need to make your own code based on your specific requirements and variation settings. Anyway a preselected variation is needed and you will need to hide the little "clear" button too (that reset all dropdowns).

    – LoicTheAztec
    Nov 29 '18 at 3:07

















What do you mean by "but I cannot seem to make it work now"? Does it show something on your browser for products with only one option? If yes, what is it? For products with more than one variation, do you have your page displayed as expected? Do you have a blank screen?

– Cedric
Nov 28 '18 at 20:31





What do you mean by "but I cannot seem to make it work now"? Does it show something on your browser for products with only one option? If yes, what is it? For products with more than one variation, do you have your page displayed as expected? Do you have a blank screen?

– Cedric
Nov 28 '18 at 20:31













You may have only one variation that does not have the default attribute as attribute, but another. (I may update the answer once you provide some more information)

– Cedric
Nov 28 '18 at 20:33





You may have only one variation that does not have the default attribute as attribute, but another. (I may update the answer once you provide some more information)

– Cedric
Nov 28 '18 at 20:33













Sorry but this code still perfectly works… But it requires that unique variation to be selected as default variation (displayed "selected" by default). If not the code doesn't work. This is specified at the beginning of the answer… So please read before saying that it don't work. Additionally if you dont make changes to a stackOverFlow answer code, Just add the link in your question.

– LoicTheAztec
Nov 29 '18 at 0:35







Sorry but this code still perfectly works… But it requires that unique variation to be selected as default variation (displayed "selected" by default). If not the code doesn't work. This is specified at the beginning of the answer… So please read before saying that it don't work. Additionally if you dont make changes to a stackOverFlow answer code, Just add the link in your question.

– LoicTheAztec
Nov 29 '18 at 0:35















Hey guys, sorry about that... This is my first time asking a question, but I am very thankful for the help. I did have a look through at the edited thread by @LoicTheAztec, and it did work but only when there is one attribute. Currently, what I have are 2 attributes. 1 of them has only 1 variation/option, and the other 1 has 3 variation/option. I would like to hide the attribute that only has one variation/option, while still showing the 1 attribute that has 3 variation/option. Just want to say sorry again for being confusing/misleading! Thanks again!

– websiteguy
Nov 29 '18 at 2:51







Hey guys, sorry about that... This is my first time asking a question, but I am very thankful for the help. I did have a look through at the edited thread by @LoicTheAztec, and it did work but only when there is one attribute. Currently, what I have are 2 attributes. 1 of them has only 1 variation/option, and the other 1 has 3 variation/option. I would like to hide the attribute that only has one variation/option, while still showing the 1 attribute that has 3 variation/option. Just want to say sorry again for being confusing/misleading! Thanks again!

– websiteguy
Nov 29 '18 at 2:51















@websiteguy As the thread title says "1 active default selected variation" … You will need to make your own code based on your specific requirements and variation settings. Anyway a preselected variation is needed and you will need to hide the little "clear" button too (that reset all dropdowns).

– LoicTheAztec
Nov 29 '18 at 3:07





@websiteguy As the thread title says "1 active default selected variation" … You will need to make your own code based on your specific requirements and variation settings. Anyway a preselected variation is needed and you will need to hide the little "clear" button too (that reset all dropdowns).

– LoicTheAztec
Nov 29 '18 at 3:07












0






active

oldest

votes












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',
autoActivateHeartbeat: false,
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%2f53525291%2fhide-dropdown-with-only-1-variable-in-woocommerce%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53525291%2fhide-dropdown-with-only-1-variable-in-woocommerce%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

Lallio

Unable to find Lightning Node

Futebolista