Home Forums WC Vendors Pro Support Cant get fields to work

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 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #60575
    patrick
    Participant

    This is a code to create a drop down choice on product-edit.

    The drop down code for product submission works fine,

    as long as its posting to:
    add_action(‘woocommerce_product_meta_start’,

    I would like it to post to:
    add_action(‘woocommerce_single_product_summary’

    but when i change it from:
    “add_action(‘woocommerce_product_meta_start’,”
    To:
    add_action(‘woocommerce_single_product_summary’

    it will not post the submitted information on the product page. Is there something else I need to change on this code?

    /* Put the below code in your product-edit.php template where you wish it to show up-- I've chosen directly before the - Product Categories -*/ 
    
    <?php 
    WCVendors_Pro_Form_Helper::select( array(  
    	'post_id'      => $object_id, 
    	'id' 	       => 'wcv_custom_product_condition',
    	'class'        => 'select2',
    	'label'        => __( 'Product Condition', 'wcvendors-pro' ), 
    	'placeholder'  => __( 'Please specify if your product is NEW or USED', 'wcvendors-pro' ),
    	'wrapper_start' 	=> '',
    	'wrapper_end' 		=> '', 
    	'desc_tip'     => 'true', 
    	'description'  => __( 'Is your Product New or Used?', 'wcvendors-pro' ),
    	'options' 	=> array(
    			'new'   => __( 'New' ),
    			'used' 	=> __( 'Used'),
    			'nwot'  => __( 'New Without Tags' ),
    	)	 
    ) );
    ?>
    
    /* Now, put the code below in your theme/child theme functions.php */
    
    add_action('woocommerce_product_meta_start', 'wcv_product_condition', 2);
    function wcv_product_condition() {
        $output = get_post_meta( get_the_ID(), 'wcv_custom_product_condition', true ); 
        echo 'Product Condition: ' . $output . '<br>';
    }
    #60603
    Anna
    Member

    Hello,
    Try removing the “2” at the end of this:
    add_action('woocommerce_product_meta_start', 'wcv_product_condition', 2);
    SO you’d have:
    add_action('woocommerce_single_product_summary', 'wcv_product_condition');

    #60692
    patrick
    Participant

    Thank you for your reply. I did more testing, the exact code above, does work, with or without the “2” works.

    But when I try to customize it then it no longer works. I have looked at the above working code and my code for hours and cant see were im messing up.

    Below is both the correct code, and my code. Can you look and see were im off? I just cant find it.

    NOTE: For some reason the wrapper start and end doesnt show up here when i copy and paste, but is in my code

    //* THE WORKING CODE FOR PRODUCT EDIT
    WCVendors_Pro_Form_Helper::select( array(  
    	'post_id'      => $object_id, 
    	'id' 	       => 'wcv_custom_product_condition',
    	'class'        => 'select2',
    	'label'        => __( 'Product Condition TEST', 'wcvendors-pro' ), 
    	'placeholder'  => __( 'Please specify if your product is NEW or USED', 'wcvendors-pro' ),
    	'wrapper_start' 	=> '',
    	'wrapper_end' 		=> '', 
    	'desc_tip'     => 'true', 
    	'description'  => __( 'Is your Product New or Used?', 'wcvendors-pro' ),
    	'options' 	=> array(
    			'new'   => __( 'New' ),
    			'used' 	=> __( 'Used'),
    			'nwot'  => __( 'New Without Tags' ),
    	)	 
    ) );
    
    //*MY NON WORKING CODE FOR PRODUCT EDIT
    WCVendors_Pro_Form_Helper::select( array(  
    	'post_id'      => $object_id, 
    	'id' 	       => 'wcv_custom_green_light',
    	'class'        => 'select2',
    	'label'        => __( 'Green Light', 'wcvendors-pro' ), 
    	'placeholder'  => __( '', 'wcvendors-pro' ),
    	'wrapper_start' 	=> '',
    	'wrapper_end' 		=> '', 
    	'desc_tip'     => 'true', 
    	'description'  => __( '', 'wcvendors-pro' ),
    	'options' 	=> array(
    			'yes'   => __( 'Yes' ),
    			'no' 	=> __( 'No'),
    	)	 
    ) );
    
    //*THE WORKING CODE FOR FUNCTIONS
    add_action('woocommerce_single_product_summary', 'wcv_product_condition');
    function wcv_product_condition() {
        $output = get_post_meta( get_the_ID(), 'wcv_custom_product_condition', true ); 
        echo 'Product Condition TEST: ' . $output . '<br>';
    }
    
    //* MY NON WORKING CODE FOR FUNCTIONS
    add_action('woocommerce_single_product_summary', 'wcv_green_light');
    function wcv_green_light() {
        $output = get_post_meta( get_the_ID(), 'wcv_custom_green_light', true ); 
        echo 'Green Light:  ' . $output . '<br>';
    }
    
    • This reply was modified 5 years, 10 months ago by patrick.
    #60886
    Anna
    Member

    This is weird..
    Each time I change the ID it will not save the selected value onto the single product page.
    ???

    So..
    For now, this works:

    <?php
    //* THE WORKING CODE FOR PRODUCT EDIT
    WCVendors_Pro_Form_Helper::select( array(  
    	'post_id'      => $object_id, 
    	'id' 	       => 'wcv_custom_product_condition',
    	'class'        => 'select2',
    	'label'        => __( 'Green Light', 'wcvendors-pro' ), 
    	'placeholder'  => __( 'Green Light?', 'wcvendors-pro' ),
    	'wrapper_start' 	=> '',
    	'wrapper_end' 		=> '', 
    	'desc_tip'     => 'true', 
    	'description'  => __( 'Green Light?', 'wcvendors-pro' ),
    	'options' 	=> array(
    			'Yes'   => __( 'Yes' ),
    			'No' 	=> __( 'No'),
    	)	 
    ) );
     ?>

    And

    add_action('woocommerce_single_product_summary', 'wcv_product_condition');
    function wcv_product_condition() {
        $output = get_post_meta( get_the_ID(), 'wcv_custom_product_condition', true ); 
        echo 'Green Light: ' . $output . '<br>';
    }
    

    But I will continue to work on why the changed id and function name is causing an issue.
    I bet it is something simply I am overlooking that I shouldn’t be… and I will feel dumb when I find it… but for now- the code above should work for you. 😉

    #60913
    patrick
    Participant

    Thank you for looking into it. I thought I was going mad. I need to make multiples of these, but it is weird changing the ID makes it not work, hopefully there’s a work around. Ill try the new code you posted and repost here an update.
    Thanks again

    • This reply was modified 5 years, 9 months ago by patrick.
    #63532
    Folasola
    Participant

    PLease where and where do i add this for this to work on my site?

    #63612
    patrick
    Participant

    The first part goes in product edit, the second in functions. You can manipalate were it displays on the product page by using woocommerce_product_meta_start or woocommerce_single_product_summary

    #65114
    Anna
    Member

    @patco
    Patrick,
    I just wanted to update you..
    I found the solution for the changed fields not displaying.
    I changed the formatting in the functions.php part of the code to include <p> and </p>
    Now it seems to show up even when you change the ID and the functions. 🙂 This should help you change your form and make more if needed.
    UPDATED:
    https://gist.github.com/fervous/048b04a4a73cde43fd77b34405917f54

    #65153
    patrick
    Participant

    Ahhhh, very nice, Much appreciated

Viewing 9 posts - 1 through 9 (of 9 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.