:) maaf adakah yg tau cara menambahkan form textarea catatan pada tiap produk woocomerce?…

maaf adakah yg tau cara menambahkan form textarea catatan pada tiap produk woocomerce?

Pake plugin apa ya kira2.. ?
Trims

Source

3 comments

  1. Nih pluginnya gratis

    // Add a custom product note below product meta in single product pages
    add_action(‘woocommerce_single_product_summary’, ‘custom_product_note’, 100 );
    function custom_product_note() {

    echo ‘

    ‘;

    woocommerce_form_field(‘customer_note’, array(
    ‘type’ => ‘textarea’,
    ‘class’ => array( ‘my-field-class form-row-wide’) ,
    ‘label’ => __(‘Product note’) ,
    ‘placeholder’ => __(‘Add your note here, please…’) ,
    ‘required’ => false,
    ) , ”);

    echo ‘

    ‘;

    //
    ?>

    ‘;
    }

    // Add customer note to cart item data
    add_filter( ‘woocommerce_add_cart_item_data’, ‘add_product_note_to_cart_item_data’, 20, 2 );
    function add_product_note_to_cart_item_data( $cart_item_data, $product_id ){
    if( isset($_POST[‘product_note’]) && ! empty($_POST[‘product_note’]) ){
    $product_note = sanitize_textarea_field( $_POST[‘product_note’] );
    $cart_item_data[‘product_note’] = $product_note;
    }
    return $cart_item_data;
    }

Leave a comment

Your email address will not be published.