Home Forums WC Vendors Pro Support Notes to Seller

NOTICE: We've Moved to a Ticket System for Support

As of August 31, 2017 (12am EST) our support forums will be retired (read-only), and we will be moving to a support ticket system.  This will allow us to better organize and answer support requests, and provide a more personalized experience as we assist our customers.

For the time being, we will leave our forums open for reading and learning while we work on creating a more robust Knowledge Base for everyone to use.

If you are a WC Vendors Pro customer please open a support ticket here. 

If you are a WC Vendors user please open a support ticket on the Wordpress.org forums.

The information on this forum is outdated and in most instances no longer relevant. Please be sure to check our documentation for the most up to date information.

https://docs.wcvendors.com/

Thank you to all of our customers!

 

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #59885
    Sara
    Participant

    Hi Anna,
    Thank you for your incredible support. I have tried to use your code to add a “Note to Seller” that is on every single product page and can then be seen in the “Order Details” in the dashboard. I used this code:

    // Message or Custom Field for the Product Page for Customers to enter text.
    // This should be added to your theme/child theme functions.php file

    /* Creates Field after add to cart button */
    function add_custom_info_field() {
    echo ‘<table class=”variations” cellspacing=”0″>
    <tbody>
    <tr>
    <td class=”label”><label for=”custom”><span style=”font-size:10px;color:#999;font-weight:400;”>Message:</span></label></td>
    <td class=”value”>
    <input type=”text” name=”custom-info-message” size=”30″value=”” placeholder=”Add a Message Here…” />
    </td>
    </tr>
    </tbody>
    </table>’;
    }
    add_action( ‘woocommerce_after_add_to_cart_button’, ‘add_custom_info_field’ );

    /* Saves field data */
    function save_add_custom_info_field( $cart_item_data, $product_id ) {
    if( isset( $_REQUEST[‘custom-info-message’] ) ) {
    $cart_item_data[ ‘custom_info_message’ ] = $_REQUEST[‘custom-info-message’];
    /* below statement make sure every add to cart action as unique line item */
    $cart_item_data[‘unique_key’] = md5( microtime().rand() );
    }
    return $cart_item_data;
    }
    add_action( ‘woocommerce_add_cart_item_data’, ‘save_add_custom_info_field’, 10, 2 );

    /* Renders field entry on cart and checkout */
    function render_mssg_meta_on_cart_and_checkout( $cart_data, $cart_item = null ) {
    $custom_items = array();
    if( !empty( $cart_data ) ) {
    $custom_items = $cart_data;
    }
    if( isset( $cart_item[‘custom_info_message’] ) ) {
    $custom_items[] = array( “name” => ‘Custom Info or Message’, “value” => $cart_item[‘custom_info_message’] );
    }
    return $custom_items;
    }
    add_filter( ‘woocommerce_get_item_data’, ‘render_mssg_meta_on_cart_and_checkout’, 10, 2 );

    /* Renders field info onto orders pages and emails */
    function custom_info_order_meta_handler( $item_id, $values, $cart_item_key ) {
    if( isset( $values[‘custom_info_message’] ) ) {
    wc_add_order_item_meta( $item_id, “custom_info_message”, $values[‘custom_info_message’] );
    }
    }
    add_action( ‘woocommerce_add_order_item_meta’, ‘custom_info_order_meta_handler’, 1, 3 );

    —————————————

    and it works perfectly. There is just one thing I am wondering about that I cannot figure out.

    I want to make it a textarea, or, a multi-line text, so that users can press “Enter” without the form adding what they have written and the item to the cart. I just can’t seem to figure out how to do this and have the form still work. Is this by any chance something that by just looking at it you could know easily what code is needed to make the form a textarea, and allow the user to press enter to separate lines of text without the product being immediately added to the cart?

    Thank you so much.

    #59944
    Anna
    Member

    Hi Sara,
    You can use this code instead (theme/child theme functions.php)- if you are using WC Vendors Pro.
    This uses our Pro forms format instead of HTML, and will make a text area (return button can be used for new lines) for the customers to use:
    https://gist.github.com/fervous/ffac7ed154a4287414ea2da675cbdc17

    #60004
    Sara
    Participant

    Anna,
    This is incredible and exactly what I needed. Thank you so very much. It is perfect.

    #60014
    Anna
    Member

    Great, Sara- I am glad this is what you were looking for. 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘WC Vendors Pro Support’ is closed to new topics and replies.
This website uses cookies to ensure you get the best experience on our website.