Forum

Thread tagged as: Question, Shop

Formatting variant_desc

I wonder if there's a way to format the output of shop's variant_desc field. My products (tickets) have really long date and location strings and in the cart it would be much easier to see if there were <br/>s between the variants instead of commas. Thanks!

Monty Lewis

Monty Lewis 2 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You could use a template filter for that https://docs.grabaperch.com/api/template-filters/

oh, wow. Perch 3!

So what field would I apply the filter to if it's the shop variant_desc I want to effect? Not even sure I know what template to attach the filter to...

Drew McLellan

Drew McLellan 2638 points
Perch Support

It would be at the point it is output to the page.

I don't think that will work in this case because the variants are going to need commas as part of their content...

Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you split on another character?

so looking at the data, I would tguess this is the field I would want to applu the filter to:

[productVariantDesc] => Adult ($155)|, Sun, Sept 24, 2017, 2pm, Ipswich High School|, Sun, Nov 26, 2017 2pm, Manchester Essex Regional High School

I've added pipe characters here to show where the variants break.

So I think perch is adding the commas, between the variant options to build that field...

Maybe I'm misunderstanding something?

Drew McLellan

Drew McLellan 2638 points
Perch Support

No, you'd be best to loop through the variants individually in that case.