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
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
I tried but no success. Do you have examples?
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
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
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
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
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
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
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
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
Hi Shane,
Could you please provide the custom code.
Sincerely, Mika
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
Hi Shane,
No. it doesn't work. Did you test it before?
Sincerely, Mika
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
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