Skip Navigation

[Resolved] Display non-Toolset fields

This thread is resolved. Here is a description of the problem and solution.

Problem:
The issue here is that the user wanted to display Non-toolset fields.

Solution:

You should be able to do this by using the shortcode in the link below.
https://toolset.com/documentation/user-guides/views-shortcodes/#vf-153444

This support ticket is created 6 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 30 replies, has 2 voices.

Last updated by Shane 6 years, 3 months ago.

Assisted by: Shane.

Author
Posts
#1088568

Hi!

I'm building auction site with Woocommerce, Simple Auctions and WC Marketplace plugins.

I'm trying to build different kinds of product listings with Toolset Views, like featured auctions, recent auctions, ending soon auctions, etc.

For this I'd need non-Toolset custom fields like WC product type, auction staring and ending dates to start.

Is it possible get these fields into to Views? If yes, how?

Sincerely, Mika

#1088610

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Mika,

Thank you for contacting our support forum.

You should be able to do this by using the shortcode in the link below.
https://toolset.com/documentation/user-guides/views-shortcodes/#vf-153444

Please let me know if this helps.
Thanks,
Shane

#1088635

I tried but no success. Do you have examples?

#1088648

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Mika,

Is it that you want to display the value of these fields on the frontend when display the posts with views?

Please let me know.
Thanks,
Shane

#1089182

Hi

Yes, display with Views in frontend.
In addition use dates to sort product listings and product type to conditionally display something.

Would nice to see real life examples using the shortcode in the similar situation.

Sincerely, Mika

#1089221

Additional info:

I can get the info from postmeta -table using this shortcode.

Woocommerce product_type seems to be stored in terms -table(s) and this is where I need help.

Sincerely, Mika

#1089498

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Mika,

If its to display then the only shortcode we have is the [wpv-post-field] if this doesn't work for it then you'll need to contact woocommerce support to see how you can display this.

However you can check under Toolset -> Settings -> Frontend -> Hidden custom fields to see if you can get the items there to display.

Thanks,
Shane

#1090107

Hi

Registering taxonomies for any plugin should be possible based on this thread: https://toolset.com/forums/topic/registering-taxonomies-from-events-manager/

Could you please check that what are the correct parameters to register WC Product Type with your development team.

// adjust to your needs
$cpt_slug = array('cutom-post-type-slug-1','cutom-post-type-slug-2');
$taxonomies_to_add = array( 'tribe_events_cat' );
// stop editing

Sincerely, Mika

#1090275

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Mika,

This solution doesn't relate to the issue you described in the thread.

Your thread mention that you want to display these fields in views.

So you're using views to display the products but you also want to display these WC custom fields using views as well, correct?

The solution in the thread is to hook WC taxonomies into a custom post type created in Types.

Would you mind allowing me to have admin access to the site as well as a link to the view that you are using to display the products?

Thanks,
Shane

#1090415

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Mika,

Would it be possible to gain access so I can take a look around so that I can give a more informed response?

Thanks,
Shane

#1090433

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Mika,

You want to get the product type.

This would need to be done with some custom code since we are not able to get the product_type with what we have available.

You can then use this custom shortcode that will return the product type in our Views conditional statement. However you must first register the shortcode name in our Views 3rd party shortcode argument in Toolset->Settings->Frontend.

This is based on what I can understand from your previous post.
Thanks,
Shane

#1091035

Hi Shane,

Could you please provide the custom code.

Sincerely, Mika

#1091276

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Mika,

Could you try this here.

// Add Shortcode
function get_wc_product_type( $atts ) {

	// Attributes
	$atts = shortcode_atts(
		array(
			'id' => '',
		),
		$atts
	);

	if ( class_exists( 'WooCommerce' ) ) {
	  // code that requires WooCommerce
	  $product_type = get_product_type($atts['id']);
	}else{
	    $product_type = "Woocommerce is not Active";
	}
	
	return $product_type;

}
add_shortcode( 'product_type', 'get_wc_product_type' );

You will can use it in views by doing this [product_type id='[wpv-post-id]']

Please try this and let me know if the product type is returned.

Thanks,
Shane

#1091293

Hi Shane,

No. it doesn't work. Did you test it before?

Sincerely, Mika

#1091302

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

product type.PNG

Hi Mika,

I made a few modification to the code.

// Add Shortcode
function get_wc_product_type( $atts ) {
 
    // Attributes
    $atts = shortcode_atts(
        array(
            'id' => '',
			'product-type'=> '',
        ),
        $atts
    );
 
    if ( class_exists( 'WooCommerce' ) ) {
      // code that requires WooCommerce
      $product_type = wc_get_product($atts['id'])->is_type($atts['product-type']);
		
    }else{
        $product_type = "Woocommerce is not Active";
    }
  
    return $product_type;
 
}
add_shortcode( 'product_type', 'get_wc_product_type' );

Now what we need to do is to check the product type of the product to see if it matches what was specified.

Example

[product_type id='[wpv-post-id]' product-type='simple']

This code will return 1 if it matches the product type and 0 if it doesn't match.

I've also attached an image of the product types.

Thanks,
Shane