Hello there,
In the listings page, I would like to show only a part (substring) of the vendor description, together with attributes.
For the moment, All I could managed to do is add an extra attribute, but the value already in the vendor profile (bio), so why duplicate it ? It’s awkward.
Here’s the solution I found out.
It seems I have to “game” the system all the time, for lack of support, or personal knowledge.
So I copy the first nth characters of the vendor’s description in the excerpt text field, whenever this field is left empty.
jQuery(document).ready(function($) {
// Listen for the form submission
$('form').on('submit', function(event) {
// Select the accroche and description fields
const $accroche = $(this).find('input[name="accroche"]');
const $description = $(this).find('textarea[name="description"]');
// Check if the accroche field is empty
if ($accroche.val().trim() === '') {
// Get the first 100 characters from the description field
const descriptionText = $description.val().trim();
const accrocheText = descriptionText.substring(0, 85);
// Set the accroche field's value if description has content
if (accrocheText.length > 0) {
$accroche.val(accrocheText);
}
}
});
});
You can adjust ‘_order’ to move the embedded description, or replace 'content' => $vendor->display_description(), with 'content' => substr($vendor->get_description(),0,123), to trim the text.