• Resolved Phil

    (@owendevelopment)


    Hi, I am using the Woocommerce product add-ons with products and have it all set up right.

    I’m trying to output the values and have it working, but they are wrapped in tags and include the label. I would want to strip these.

    CUrrent output:

    <dl class="variation">
    <dt class="variation-WebsiteDomain">Website Domain:</dt>
    <dd class="variation-WebsiteDomain">
    <p>
    <a rel="nofollow" href="http://mytest.com">http://mytest.com</a>
    </p>
    </dd>
    </dl>

    I would just like the value on it’s own, namely ‘http://mytest.com&#8217;.

    Anyone had an experience with this before? The code I’m using to generate and display the variation data is:

    $_product  = apply_filters( 'woocommerce_subscriptions_order_item_product', $subscription->get_product_from_item( $item ), $item );
    $item_meta = wcs_get_order_item_meta( $item, $_product );
    if ( apply_filters( 'woocommerce_order_item_visible', true, $item ) ) {
    $item_meta->display();
    }
Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator James Huff

    (@macmanx)

    Volunteer Moderator

    Since that is a commercial plugin, we ask that you please go to their official support channel, so you can get support from the people who know it best.

    https://woothemes.com/my-account/create-a-ticket/

    Forum volunteers are also not given access to commercial products, so they would not know why it is not working properly. Other community members who may have faced your issue might be able to help you but your best bet is your product’s developer. Keep in mind we encourage you to use the official support venues, as it allows the developers to be aware of issues with their code and gives back to the community in a more robust way.

    Thread Starter Phil

    (@owendevelopment)

    Hi James,

    Actually I think the Product Add-ons are merely just adding custom fields and are created as product meta so more part of WooCommerce core.

    I traced the function in Woo, in woocommerce/includes/class-wc-order-item-meta.php. And this is the bit I need to edit:

    /**
    	 * Display meta in a formatted list.
    	 *
    	 * @param bool $flat (default: false)
    	 * @param bool $return (default: false)
    	 * @param string $hideprefix (default: _)
    	 * @param  string $delimiter Delimiter used to separate items when $flat is true
    	 * @return string|void
    	 */
    	public function display( $flat = false, $return = false, $hideprefix = '_', $delimiter = ", \n" ) {
    		$output         = '';
    		$formatted_meta = $this->get_formatted( $hideprefix );
    
    		if ( ! empty( $formatted_meta ) ) {
    			$meta_list = array();
    
    			foreach ( $formatted_meta as $meta ) {
    				if ( $flat ) {
    					$meta_list[] = wp_kses_post( $meta['label'] . ': ' . $meta['value'] );
    				} else {
    					$meta_list[] = '
    						<dt class="variation-' . sanitize_html_class( sanitize_text_field( $meta['key'] ) ) . '">' . wp_kses_post( $meta['label'] ) . ':</dt>
    						<dd class="variation-' . sanitize_html_class( sanitize_text_field( $meta['key'] ) ) . '">' . wp_kses_post( wpautop( make_clickable( $meta['value'] ) ) ) . '</dd>
    					';
    				}
    			}
    
    			if ( ! empty( $meta_list ) ) {
    				if ( $flat ) {
    					$output .= implode( $delimiter, $meta_list );
    				} else {
    					$output .= '<dl class="variation">' . implode( '', $meta_list ) . '</dl>';
    				}
    			}
    		}
    
    		$output = apply_filters( 'woocommerce_order_items_meta_display', $output, $this );
    
    		if ( $return ) {
    			return $output;
    		} else {
    			echo $output;
    		}
    	}

    Is there a way to override this function?

    Moderator James Huff

    (@macmanx)

    Volunteer Moderator

    Ok, if it’s a problem in WooCommerce core, then I recommend asking at https://wordpress.org/support/plugin/woocommerce#postform so the plugin’s developers and support community can help you with this.

    Thread Starter Phil

    (@owendevelopment)

    Done, thanks

    Moderator James Huff

    (@macmanx)

    Volunteer Moderator

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Woocommerce Product Add-ons – Strip label’ is closed to new replies.