• Resolved 2candela2

    (@2candela2)


    Hello and thanks

    I am building a multivendor site with Dokan-lite for 4 small teaching cooperatives. I have found this code for adding custom fields to the edit product form. It works well with simple fields, but with the pods repeatable one I don’t get the button to repeat, nor the date and time selection. Could you please tell to me how to solve it? I think that I have to load to the page some javascript, don’t I? Or maybe something else that you use with the fields to repeat them. Thanks

    /*
    * Adding extra field on New product popup/without popup form
    */

    add_action( 'dokan_new_product_after_product_tags','new_product_field',10 );

    function new_product_field(){ ?>

    <div class="dokan-form-group custom-fields">

    <!-- field format: date/time, repetable. name: horari -->
    <input type="text" id="pods-form-ui-pods-meta-horari" name="pods-form-ui-pods-meta-horari" class="pods-form-ui-field pods-form-ui-field-type-datetime pods-form-ui-field pods-form-ui-field-type-time pods-form-ui-field-name-pods-meta-horari pods-validate pods-validate-required" value="">

    </div>

    <?php
    }

    /*
    * Saving product field data for edit and update
    */

    add_action( 'dokan_new_product_added','save_add_product_meta', 10, 2 );
    add_action( 'dokan_product_updated', 'save_add_product_meta', 10, 2 );

    function save_add_product_meta($product_id, $postdata){

    if ( ! dokan_is_user_seller( get_current_user_id() ) ) {
    return;
    }

    //field format: format: date/time, repetable. name: horari
    if ( ! empty( $postdata['pods-form-ui-pods-meta-horari'] ) ) {
    update_post_meta( $product_id, 'pods-form-ui-pods-meta-horari', $postdata['pods-form-ui-pods-meta-horari'] );
    }

    }

    /*
    * Showing field data on product edit page
    */

    add_action('dokan_product_edit_after_product_tags','show_on_edit_page',99,2);

    function show_on_edit_page($post, $post_id){

    ?>
    <!-- field format: date/time, repetable. name: horari -->
    <?php $new_field = get_post_meta( $post_id, 'pods-form-ui-pods-meta-horari', true ); ?>
    <input type="hidden" name="pods-form-ui-pods-meta-horari" id="dokan-edit-product-id" value="<?php echo esc_attr( $post_id ); ?>"/>
    <label for="pods-form-ui-pods-meta-horari" class="form-label">Horari</label>
    <?php dokan_post_input_box( $post_id, 'pods-form-ui-pods-meta-horari', array( 'placeholder' => __( 'Text per horari', 'dokan-lite' ), 'value' => $new_field ) ); ?>

    </div> <?php

    }

    // showing on single product page
    add_action('woocommerce_single_product_summary','show_product_code',13);

    function show_product_code(){
    global $product;

    if ( empty( $product ) ) {
    return;
    }

    //field format: date/time, repetable. name: horari
    $new_field = get_post_meta( $product->get_id(), 'pods-form-ui-pods-meta-horari', true );
    if ( ! empty( $new_field ) ) {
    ?>
    <span class="details"><?php echo esc_attr__( 'Horari:', 'dokan-lite' ); ?> <strong><?php echo esc_attr( $new_field ); ?></strong></span>
    <?php
    }

    }

    Have a good day

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter 2candela2

    (@2candela2)

    Dokan-lite uses fronted theme to edit the products. All the fields work ok in the admin area with the first WordPress user and role administrator, with the repeatable field working as configured.

    • This reply was modified 8 months, 3 weeks ago by 2candela2.
    Thread Starter 2candela2

    (@2candela2)

    Is it a way to bring pods edit content type to frontend? Thanks

    Thread Starter 2candela2

    (@2candela2)

    I am trying with the pods form block and it charges ok, but it doesn’t affect the Dokan form.

    By the way how you pass the current page for the form to edit the current product? The url is:

    https://test.test/dashboard/products/?product_id=958&action=edit&_dokan_edit_product_nonce=ece6266bcd

    I tried to put in the SLUG OR ID field in the form block the magic tag {@get.product_id} , but it don’t work. Thanks

    Thread Starter 2candela2

    (@2candela2)

    Again thanks for pods!
    I am learning how to use this very complete plugin!

    I found how to do it thanks to a person that posted the solution.

    My field is “durada”

    <?php 
    $pods = pods( 'product', $post_id );
    // Specify which fields to show.
    $params = array( 'fields_only' => true, 'fields' => array('durada') );
    // Output the form.
    echo $pods->form( $params );
    ?>

    Great your plugin!!!

    • This reply was modified 8 months, 2 weeks ago by 2candela2.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Dokan-lite: Repetable fields compatibility’ is closed to new replies.