相关疑难解决方法(0)

Dynamic shipping fee based on custom radio buttons in Woocommerce

In Woocommerce, I have added two custom radio buttons on the checkout page and on click, I called an ajax function to add a delivery fee.

Here is my code:

$(document).on('change','#shipping_method_0_local_pickup5',function(e) {              
            $('.woocommerce-shipping-fields').css({
                'display': 'none'
            });

                        $("#deli").css("display","block"); 
                        var selected = $("input[type='radio'][name='post-del']:checked");
                        var selectedVal = selected.val();               
                        var pickurl= "<?php echo admin_url('admin-ajax.php');?>?action=delivery";
                        $.ajax({   
                            url: pickurl,
                            type: "POST",
                            data:{
                                input:selectedVal,                       
                            },            
                            success: function(responseText) 
                            { 
                                jQuery(".order-total .woocommerce-Price-amount").html(responseText);
                                //$(".discount_code").css("display","block"); 
                            }
                        }); 

        });
Run Code Online (Sandbox Code Playgroud)

when the radio button click I want to add addition price $2 on …

php ajax jquery cart woocommerce

5
推荐指数
1
解决办法
2278
查看次数

在 Woocommerce 结帐页面中显示添加费用的复选框

在 Woocommerce 结帐页面中,我尝试在结帐页面上添加一个复选框

\n\n

我参考过这些文章

\n\n

woocommerce 自定义结帐字段添加费用以订购 ajax\n

\n\n

在 WooCommerce 中添加/删除自定义费用的复选框字段

\n\n

添加一个结账复选框字段,在 Woocommerce 中启用百分比费用\n

\n\n
add_action( \'woocommerce_review_order_before_order_total\', \'checkout_shipping_form_packing_addition\', 20 );\nfunction checkout_shipping_form_packing_addition( ){\necho \'<tr class="packing-select"><th>\';\nwoocommerce_form_field( \'add_gift_box\', array(\n    \'type\'          => \'checkbox\',\n    \'class\'         => array(\'add_gift_box form-row-wide\'),\n    \'label\'         => __(\'H\xe1\xbb\x97 tr\xe1\xbb\xa3 c\xc3\xa0i \xc4\x91\xe1\xba\xb7t\'),\n    \'placeholder\'   => __(\'\'),\n    ));\necho \'</th><td>\';}\n\nadd_action( \'wp_footer\', \'woocommerce_add_gift_box\' );\nfunction woocommerce_add_gift_box() {\nif (is_checkout()) {\n?>\n<script type="text/javascript">\njQuery( document ).ready(function( $ ) {\n    $(\'#add_gift_box\').click(function(){\n        jQuery(\'body\').trigger(\'update_checkout\');\n    });\n});\n</script>\n<?php\n}}\nadd_action( \'woocommerce_cart_calculate_fees\', \'woo_add_cart_fee\' );\nfunction woo_add_cart_fee( $cart ){\n    if ( ! $_POST || ( is_admin() && ! is_ajax() ) …
Run Code Online (Sandbox Code Playgroud)

php ajax jquery checkout woocommerce

5
推荐指数
1
解决办法
5708
查看次数

标签 统计

ajax ×2

jquery ×2

php ×2

woocommerce ×2

cart ×1

checkout ×1