Skip Navigation

[Resolved] insert toolset post meta and various taxonomie in php woocomerce template

This support ticket is created 4 years, 8 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 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by Luo Yang 4 years, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#1808783
product-sample.png

Tell us what you are trying to do?

I m trying to insert a more complete description in my product by adding toolset customfields

i have some different type fields :

1 : a simple toolset text field = i want do an php echo into div
2 : woocommerce description (defaut template)
3 : product attribute taxonomie = i would display taxonomie active in this attribute *
4 : toolset or woocommerce taxonomie : i would display image based on the name of taxonomie and link

Is there any documentation that you are following?

https://toolset.com/forums/topic/insert-wpv-conditional-in-php-output-template/
hidden link
https://developer.wordpress.org/reference/functions/the_content/
https://developer.wordpress.org/reference/functions/get_post_meta/

Is there a similar example that we can see?

What is the link to your site?

the website is underconstruction, tell me if you need credentials

////////////////////////

I m trying do test based on this code

# images (but here its a boolean)
global $post;
$vin_nature = get_post_meta( $post->ID, 'wpcf-vin-nature', true );
if( int_val($vin_nature) == 1 ) {
echo "<img src="hidden link" alt="Vin Nature" />"
}

#clickable taxonomie (i m going to replace $attribute_taxonomy by the id of taxonomie)
$value_name = esc_html( $attribute_value->name );

if ( $attribute_taxonomy->attribute_public ) {
$values[] = 'term_id, $attribute->get_name() ) ) . '" rel="tag">' . $value_name . '';
} else {
$values[] = $value_name;
}
}
} else {
$values = $attribute->get_options();

foreach ( $values as &$value ) {
$value = make_clickable( esc_html( $value ) );
}
}

#1808795

a part of description section of template :

<div>
<img src="hidden link">
aaa bbbb<img src="hidden link">
</div>

<?php
/**
* Single product short description
*
* @version 3.3.0
*/

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

global $post;

$short_description = apply_filters( 'woocommerce_short_description', $post->post_excerpt );

if ( ! $short_description ) {
return;
}
?>

<div class="description woocommerce-product-details__short-description">
<?php echo ! $short_description ? '' : $short_description; // WPCS: XSS ok. ?>
</div>

<?php
/**
*

global $post;
$vin_nature = get_post_meta( $post->ID, 'wpcf-vin-nature', true );
$vin_nature = get_post_meta( $post->ID, 'wpcf-vin-nature', true );
if( int_val($vin_nature) == 1 ) {
echo "<img src="hidden link" alt="Vin Nature" />"
}

*/

?>

<div id="tableau">
<table>
<tbody>
<tr>
<td style="text-align: left; font-family: Open Sans; background-color:#eeeeee;">Région:</td>
<td style="font-size: 15px;text-align: left; font-family: Open Sans; color: #ee337c"><b> Cépages </b></td>
</tr>
<tr>
<td style="text-align: left; font-family: Open Sans; background-color:#eeeeee;">Appelation:</td>
<td style="font-size: 15px;text-align: left; font-family: Open Sans; color: #ee337c"><b> Cépages </b></td>
</tr><tr>
<td style="text-align: left; font-family: Open Sans; background-color:#eeeeee;">Cépages:</td>
<td style="font-size: 15px;text-align: left; font-family: Open Sans; color: #ee337c"><b> Cépages </b></td>
</tr>
</tbody>
</table>
</div>

<div>
Label(s)<br>
<img src="hidden link">
<img src="hidden link">
<img src="hidden link">
<img src="hidden link">
</div>

<div>
Récompense(s)<br>
<img src="hidden link">
<img src="hidden link">
<img src="hidden link">
<img src="hidden link">
</div>

#1809985

Hello,

You can follow our document to setup the custom PHP codes to render the custom fields created with Toolset Types plugin:
https://toolset.com/documentation/customizing-sites-using-php/functions/

For taxonomies, please check this document:
https://toolset.com/documentation/customizing-sites-using-php/creating-templates-single-custom-posts/#displaying-custom-taxonomy
section "Displaying custom taxonomy"

#1816493

i would like convert this : {!{wpv-conditional if="( CONTAINS(#(recompense-producteur),'Guide Hachette') )"}!} HTML image [/wpv-conditional] into this in php

based on tutorial : the tutrial call the term list, i want display an image

<!-- TYPES TIP: Custom call to get_the_term_list function to display a list of taxonomy terms that the current "Consultant" post belongs to -->
<?php echo get_the_term_list( $post->ID, 'spoken-language', '<p>Spoken languages: ', ', ', '</p>'); ?>

i have tried this :

<?php

global $post;
$hachette = get_the_term_list( $post->ID, 'recompense-producteur', true );
if( contains($vin_nature) == Guide Hacette ) {
echo "<img src="hidden link" alt="Vin Nature" />"
}
?>

guide hachette is a term of a flat taxonomie in award

#1816961

You can use WordPress function has_term() to check current post has specific terms, see WP document:
https://developer.wordpress.org/reference/functions/has_term/