在woocommerce中自定义产品插件部分?

时间:2022-10-25 10:05:55

I am working on an ecommerce project I have added the product addons on the product page with four options. I want to add a radio button for the first upload option and when user selects that option I want to give the user the upload option. I am not sure how to do this, which files i will have to edit !to add this functionality ?

我正在开发一个电子商务项目,我在产品页面上添加了产品插件,有四个选项。我想为第一个上传选项添加一个单选按钮,当用户选择该选项时,我想给用户上传选项。我不知道怎么做,我必须编辑哪些文件!添加此功能?

Do I have to change the functions.php in the themes folder of wordpress ?

我是否必须更改wordpress的themes文件夹中的functions.php?

在woocommerce中自定义产品插件部分?

1 个解决方案

#1


WordPress is limited only by your imagination

WordPress只受你想象力的限制

And it trully is - there are thousands of different plugins, themes, add-ons, etc. for your WordPress. Without knowing what exactly are you talking about it is just a shot in the dark.

它真的很棒 - 你的WordPress有成千上万种不同的插件,主题,附加组件等。不知道你究竟在说什么,它只是在黑暗中拍摄。

I want to add a radio button for the first upload option and when user selects that option I want to give the user the upload option.

我想为第一个上传选项添加一个单选按钮,当用户选择该选项时,我想给用户上传选项。

The following code snippet does the job for you (add style, more functionality)

以下代码片段为您完成工作(添加样式,更多功能)

<form id="form_1" type='application/x-www-form-urlencoded' method="post">
    <label for="product_1">Product 1</label>
        <input form="form_1" type="radio" value="1" name="products" id="product_1" />
        <input form="form_2" type="file" name="products" id="product_1_upload" style="display: none;" /><br>
    <label for="product_2">Product 2</label><input form="form_1" type="radio" value="2" name="products" id="product_2" /><br>
    <label for="product_3">Product 3</label><input form="form_1" type="radio" value="3" name="products" id="product_3" /><br>
</form>
<form id="form_2" method="post" enctype='multipart/form-data'></form>

<button id="form_submit"/>Submit</button>

<script>

    $('input[type=radio][name=products]').change(function()
    {
        if ($('#product_1').prop('checked') == true)
        {
            $('#product_1').css({'display' : 'none'});
            $('#product_1_upload').css({'display' : 'inline-block'});
        }
        else
        {
            $('#product_1').css({'display' : 'inline-block'});
            $('#product_1_upload').css({'display' : 'none'});
        }
    });

    $('#form_submit').click(function()
    {           
        if ($('#product_1_upload').val() || $('#product_1').prop('checked') == true)
        {
            $('#form_2').submit();
        }
        else
        {
            $('#form_1').submit();
        }
    });

</script>

#1


WordPress is limited only by your imagination

WordPress只受你想象力的限制

And it trully is - there are thousands of different plugins, themes, add-ons, etc. for your WordPress. Without knowing what exactly are you talking about it is just a shot in the dark.

它真的很棒 - 你的WordPress有成千上万种不同的插件,主题,附加组件等。不知道你究竟在说什么,它只是在黑暗中拍摄。

I want to add a radio button for the first upload option and when user selects that option I want to give the user the upload option.

我想为第一个上传选项添加一个单选按钮,当用户选择该选项时,我想给用户上传选项。

The following code snippet does the job for you (add style, more functionality)

以下代码片段为您完成工作(添加样式,更多功能)

<form id="form_1" type='application/x-www-form-urlencoded' method="post">
    <label for="product_1">Product 1</label>
        <input form="form_1" type="radio" value="1" name="products" id="product_1" />
        <input form="form_2" type="file" name="products" id="product_1_upload" style="display: none;" /><br>
    <label for="product_2">Product 2</label><input form="form_1" type="radio" value="2" name="products" id="product_2" /><br>
    <label for="product_3">Product 3</label><input form="form_1" type="radio" value="3" name="products" id="product_3" /><br>
</form>
<form id="form_2" method="post" enctype='multipart/form-data'></form>

<button id="form_submit"/>Submit</button>

<script>

    $('input[type=radio][name=products]').change(function()
    {
        if ($('#product_1').prop('checked') == true)
        {
            $('#product_1').css({'display' : 'none'});
            $('#product_1_upload').css({'display' : 'inline-block'});
        }
        else
        {
            $('#product_1').css({'display' : 'inline-block'});
            $('#product_1_upload').css({'display' : 'none'});
        }
    });

    $('#form_submit').click(function()
    {           
        if ($('#product_1_upload').val() || $('#product_1').prop('checked') == true)
        {
            $('#form_2').submit();
        }
        else
        {
            $('#form_1').submit();
        }
    });

</script>