• Resolved davemktg86

    (@davemktg86)


    Hi!
    I’m trying to add a unit of measure to the quote tab (yith plugin). yith developer told me how to add the column. I added it with the title “unit of measure” but I’m not able to return the unit of measure value(php?). I also tryed to search how uom plugin return this value in single product page(to copy that) but I don’t find it. Please, can you help me?

    thanks in advance
    regards

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Brad Davis

    (@brad-davis)

    Hi Dave,

    The uom text gets attached to the price string before being displayed, the below will show you how to get the value and display it, but it will be still attached to the price. One option would be to hide the one attached to the price with css

    This will get the value from the database

    
    $dmkt_uom_output = get_post_meta( $post->ID, '_woo_uom_input', true );
    

    This will display it

    
    esc_attr_e( 'dmkt_uom_output', 'dave-text-domain-here' );
    

    Hide the standard uom with css

    
    uom {
      display: none;
    }
    

    Cheers
    Brad

    Thread Starter davemktg86

    (@davemktg86)

    Thank you very much! but I do not understand where I’m wrong …

    <td class="product-uom" data-title="Unit of Measure">
                        <?php
                        $dmkt_uom_output = get_post_meta( $post->ID, '_woo_uom_input', true );
                        esc_attr_e( "dmkt_uom_output", 'yith-woocommerce-request-a-quote' );
                        ?>
    </td> 

    Using this code it returns only this text: “dmkt_uom_output”.

    regards

    Plugin Author Brad Davis

    (@brad-davis)

    Oh sorry Dave, my mistake, change it to:

    
    esc_attr_e( $dmkt_uom_output, 'yith-woocommerce-request-a-quote' );
    
    Thread Starter davemktg86

    (@davemktg86)

    Thanks, It’s the same as I thought, I tried it, but it does not work anyway. With $dmkt_uom_output it should return the variable value, but nothing appears. And I don’t understand why…

    Plugin Author Brad Davis

    (@brad-davis)

    Hi Dave,

    Just to confirm, this Unit of measure plugin is installed, active and you have added a value into the input field on the product you are looking at?

    Are you getting any error messages returned? eg, Undefined variable: post….. or Trying to get property of non-object ??

    If so I would say that when you are adding the code snippet you don’t have access to the global $post variable. So you can get access to the variable with global $post, eg,

    
    global $post
    $dmkt_uom_output = get_post_meta( $post->ID, '_woo_uom_input', true );
    esc_attr_e( $dmkt_uom_output, 'yith-woocommerce-request-a-quote' );
    

    or you can also use get_the_id() like this:

    
    $dmkt_uom_output = get_post_meta( get_the_ID(), '_woo_uom_input', true );
    esc_attr_e( $dmkt_uom_output, 'yith-woocommerce-request-a-quote' );
    

    Let me know how you go.

    Cheers
    Brad

    Thread Starter davemktg86

    (@davemktg86)

    Hi!
    yes, the plugin is active and the value is in the input field! but nothing, also with these last codes it doesn’t show the uom. And and it does not give me any error message. I really dont’t know. I’m desperate!

    ps: on the other hand, the unit of measure appears on the single product page even without price, and I don’t know how…

    Thread Starter davemktg86

    (@davemktg86)

    I have a doubt…where you wrote ‘dave-text-domain-here’, I entered ‘yith-woocommerce-request-a-quote’….is this right?

    Plugin Author Brad Davis

    (@brad-davis)

    Hi Dave,

    The ‘dave-text-domain-here’/‘yithu-woocommerce-request-a-quote’ is not really important in the function, the text domain is used for translation.

    How are you adding the code snippets and where are you looking to display the info. Also do you have a link to an example page?

    Cheers
    Brad

    Thread Starter davemktg86

    (@davemktg86)

    Hi!
    thanks for the clarification!

    I’m trying to display it in the request a quote page(yith plugin).
    Here some screenshot:
    product page: https://prntscr.com/kzalow
    request a quote page: https://prntscr.com/kzalzw
    code: https://prntscr.com/kzam5i

    regards

    Plugin Author Brad Davis

    (@brad-davis)

    Hi Dave,

    Oh right, ok. Sorry I thought you were adding it in another location on the single product page.

    From the screenshot, remove line 130 ‘global $post’ and then line 131 either

    
    $dmkt_uom_output = get_post_meta( $_product->ID, '_woo_uom_input', true );
    

    or

    
    $dmkt_uom_output = get_post_meta( $_product->post->ID, '_woo_uom_input', true );
    

    Let me know.

    Cheers
    Brad

    Thread Starter davemktg86

    (@davemktg86)

    it works!
    thank you very much!

    regards

    Plugin Author Brad Davis

    (@brad-davis)

    Great to hear Dave.

    Cheers
    Brad

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Add Unit of Measure to Yith Request a Quote tab’ is closed to new replies.