亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

? ??? ?? PHP ???? WooCommerce Checkout?? ??? ?? ??? ?? ?? ???? ???? ??? ??????

WooCommerce Checkout?? ??? ?? ??? ?? ?? ???? ???? ??? ??????

Oct 20, 2024 pm 05:55 PM

How to implement a Dynamic Fee Based on Radio Button Selection in WooCommerce Checkout?

WooCommerce ????? ??? ?? ??? ?? ?? ???

WooCommerce ????? ??? ?? ??? ?? ?? ???? ????? ?? ??? ?????:

??? ?? ?? ??? ??

woocommerce_form_field_radio ??? ?????? ??? ?? ?? ??? ?????. ??? ?? ??? ????? ???? ??? ??? ??? ? ????.

<code class="php">add_action( 'woocommerce_form_field_radio', 'custom_form_field_radio', 20, 4 );
function custom_form_field_radio( $field, $key, $args, $value ) {
    if ( ! empty( $args['options'] ) &amp;&amp; is_checkout() ) {
        $field = str_replace( '</label><input ', '</label><br><input ', $field );
        $field = str_replace( '<label ', '<label style="display:inline;margin-left:8px;" ', $field );
    }
    return $field;
}

?? ?? ??? ??

woocommerce_cart_calculate_fees? ???? ?? ?? ???? ?????. ???? ??? ?? ??? ???? ??? ???? ?????.

<code class="php">add_action( 'woocommerce_cart_calculate_fees', 'add_packaging_fee', 20, 1 );
function add_packaging_fee( $cart ) {
    if ( is_admin() &amp;&amp; ! defined( 'DOING_AJAX' ) )
        return;

    $packing_fee = WC()->session->get( 'chosen_packing' ); // Dynamic packing fee
    $fee = $packing_fee === 'box' ? 9.00 : 3.00;
    $cart->add_fee( __( 'Packaging fee', 'woocommerce' ), $fee );
}</code>

??? ?? ?? ??

woocommerce_review_order_after_shipping? ???? ??? ?? ??? ?? ??? ?????. ??? ???.

<code class="php">add_action( 'woocommerce_review_order_after_shipping', 'checkout_shipping_form_packing_addition', 20 );
function checkout_shipping_form_packing_addition() {
    $domain = 'woocommerce';

    echo '<tr class="packing-select"><th>' . __('Packing options', $domain) . '</th><td>';

    $chosen   = WC()->session->get('chosen_packing');
    $chosen   = empty($chosen) ? WC()->checkout->get_value('radio_packing') : $chosen;
    $chosen   = empty($chosen) ? 'bag' : $chosen;

    // Add a custom checkbox field
    woocommerce_form_field( 'radio_packing', array(
        'type' => 'radio',
        'class' => array( 'form-row-wide packing' ),
        'options' => array(
            'bag' => __('In a bag '.wc_price(3.00), $domain),
            'box' => __('In a gift box '.wc_price(9.00), $domain),
        ),
        'default' => $chosen,
    ), $chosen );

    echo '</td></tr>';
}</code>

jQuery ? Ajax ????

? ????? ??? ?? ?? ? ??? ????? ?? Ajax ??? ?????.

<code class="php">add_action( 'wp_footer', 'checkout_shipping_packing_script' );
function checkout_shipping_packing_script() {
    if ( ! is_checkout() )
        return; // Only checkout page
    ?>
    <script type="text/javascript">
    jQuery( function($){
        $('form.checkout').on('change', 'input[name=radio_packing]', function(e){
            e.preventDefault();
            var p = $(this).val();
            $.ajax({
                type: 'POST',
                url: wc_checkout_params.ajax_url,
                data: {
                    'action': 'woo_get_ajax_data',
                    'packing': p,
                },
                success: function (result) {
                    $('body').trigger('update_checkout');
                    console.log('response: '+result); // just for testing | TO BE REMOVED
                },
                error: function(error){
                    console.log(error); // just for testing | TO BE REMOVED
                }
            });
        });
    });
    </script>
    <?php

}

PHP Ajax ??

Ajax ??? ???? ??? ?? ??? ???? ???? ?????.

<code class="php">add_action( 'wp_ajax_woo_get_ajax_data', 'woo_get_ajax_data' );
add_action( 'wp_ajax_nopriv_woo_get_ajax_data', 'woo_get_ajax_data' );
function woo_get_ajax_data() {
    if ( isset($_POST['packing']) ){
        $packing = sanitize_key( $_POST['packing'] );
        WC()->session->set('chosen_packing', $packing );
        echo json_encode( $packing );
    }
    die(); // Alway at the end (to avoid server error 500)
}</code>

? ???? jQuery, Ajax, ??? ?? ??? ?? ???? ???? ?????? ??? WooCommerce ??? ?? ?? ? ??? ??? ??? ?????.

? ??? WooCommerce Checkout?? ??? ?? ??? ?? ?? ???? ???? ??? ??????? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? ????? ??
? ?? ??? ????? ???? ??? ??????, ???? ?????? ????. ? ???? ?? ???? ?? ??? ?? ????. ???? ??? ???? ???? ??? ?? admin@php.cn?? ?????.

? AI ??

Undresser.AI Undress

Undresser.AI Undress

???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover

AI Clothes Remover

???? ?? ???? ??? AI ?????.

Video Face Swap

Video Face Swap

??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

???

?? ??

???

??? ??

???++7.3.1

???++7.3.1

???? ?? ?? ?? ???

SublimeText3 ??? ??

SublimeText3 ??? ??

??? ??, ???? ?? ????.

???? 13.0.1 ???

???? 13.0.1 ???

??? PHP ?? ?? ??

???? CS6

???? CS6

??? ? ?? ??

SublimeText3 Mac ??

SublimeText3 Mac ??

? ??? ?? ?? ?????(SublimeText3)

???

??? ??

C# ????
1474
30
NYT ?? ??? ??
81
618
???
PHP ??? ?? ???? : ?? ?? PHP ??? ?? ???? : ?? ?? May 13, 2025 am 12:11 AM

aphpdectionenceindectioncontainerisatoolthatmanagesclassdependencies, ?? Codemodularity, testability ? maintainability.itactAsacentralHubForCreatingAndingDinjectingDingingDingingdecting.

PHP ?? ??? ??. PHP ?? ??? ??. May 13, 2025 am 12:06 AM

phPapplicationSCanBeoptimizedForsPeedandefficiencyby : 1) ENABLEOPCACHEINPHP.INI, 2) PREPAREDSTATEMENTSWITHPDOFORDATABASEQUERIES ??

PHP ??? ?? : ???? ???? ???????? PHP ??? ?? : ???? ???? ???????? May 13, 2025 am 12:06 AM

phpeMailValidationInvoLvestHreesteps : 1) formatValidationUsingRegularexpressionsTochemailformat; 2) dnsValidationToErethedomainHasaValidMxRecord; 3) smtpvalidation, theSTHOROUGHMETHOD, theCheckSiftheCefTHECCECKSOCCONNECTERTETETETETETETWERTETWERTETWER

PHP ?? ??? : Opcode ?? ?? PHP ?? ??? : Opcode ?? ?? May 07, 2025 pm 02:49 PM

opCodeCachingsIntIficInlyIntImeRimproveSphpperformanceCachingCompileDCode, retingServerLoadandResponsEtimes.1) itStoresCompyledPhpCodeInMemory, BYPASSINGPARSINGCOMPILING.2) UseOpCacheSettingParametersInphP.Ini, likeMoryConsAncme AD

PHP? ??? ????? ?? ?? PHP? ??? ????? ?? ?? May 08, 2025 am 12:21 AM

??? ?? (DI)? ???? ??? ??? ??? ?? ?, ??? ??? ? ?? ?? ???? ???? ?????. 1) ???? ???? ???? ????, 2) ??? ???? ??? ???, 3) ??? ?? ????? ???? ???? ????, 4) ?? ???? ?? ??? ???? ?? ?????.

PHP?? ?? ?? ?? ???? ???? ??? ?????? PHP?? ?? ?? ?? ???? ???? ??? ?????? May 23, 2025 pm 08:21 PM

?? ?? ?? ??? ??? ? ?? ? ??? ??? ?? PHP?? ?????. 1) ?? ???? ???? ??? ???? ?? ??? ??????. 2) ??? ??? 18 ???? ??????. 3) ??? ??? ??? ????? ???? ?? ?? ??? ???? ??????.

PHP ??? ?? : ?? ??? ???? ?????? PHP ??? ?? : ?? ??? ???? ?????? May 12, 2025 am 12:03 AM

??? ?? (DI)? ?? ??? ??? ???? ?? PHP ??? ??? ???? ?? ??????. 1) DI ?? ?? ? ??? ? ?? ??? ??? ? ?? ????? ???? ????. 2) ? ?? ?? ???, ???? ??? ????? ???? ?? ?? ? ?? ???? ?????. 3) DI ????? ???? ??? ???? ???? ?? ?? ? ?? ???? ??????.

PHP? ??? ?? ? ??? ???? PHP? ??? ?? ? ??? ???? May 13, 2025 am 12:10 AM

??? ?? ????? ?? SELLENCIONINGESS (DI)? ??????. ServicElocator? ??? ???? ?? ??? ??? ?????. 1) DI? ??? ??? ?? ??? ??? ???? ???? ??????. 2) Servicelocator? ?? ??? ?? ???? ????. ?? ????? ?? ?? ?? ?? ? ? ????.

See all articles