Support

Home Forums Event Espresso Premium Slash-pricing Sale-pricing with strikethrough best practice?

Slash-pricing Sale-pricing with strikethrough best practice?

Posted: May 21, 2020 at 1:50 pm


Daniel

May 21, 2020 at 1:50 pm

I searched and could not find and answer to this question on the forums yet.

We want to display a “strikethrough price” that is the “original” price and at the same time display and sell a ticket with the sale price.

Is there a best-practice for this using EE?

I thought of storing the original price somewhere hidden in the ticket like you can with Event Meta but I don’t think there is a Ticket Meta.

The best I could come up with was to create a force sold-out ticket (0 quantity) and use some CSS and JS to do the re-formatting of the ticket selector – remove the Sold Out wording and change the price to a strikethrough.

I am not that happy about this solution as it seems kind of weird.


// added this to CSS: tr.ticket-sales-sold-out > td:nth-child(3) {display: none;}
// get the price
var total = document.querySelector('tr.ticket-sales-sold-out > td:nth-child(2)').textContent.match(/[\d]+\.[\d]+/g);
// do a srikethrough on the price
document.querySelector('tr.ticket-sales-sold-out > td:nth-child(2)').innerHTML = '<span class="alignleft">  $<s>'+total+'</s></span>';

Any suggestions how to do this in the “EE” way?

Thanks!


Tony

  • Support Staff

May 22, 2020 at 4:07 am

Hi Daniel,

With EE, everything has meta 🙂 it’s extra_meta.

https://github.com/eventespresso/event-espresso-core/blob/dce71d47e8158513b989cd34fb7a0c1ce86e6f09/core/db_models/EEM_Extra_Meta.model.php

Note that querying based on extra_meta is inefficient and not straightforward, but pretty much any entity within EE can have extra_meta attached to it.

So there’s nothing stopping you from saving extra_meta for a ticket, if you have an EE_Ticket object within $ticket you can do something like:

$ticket->update_extra_meta('daniel_sale_price', {value} );

To store a sale price value.

I’d recommend adding a field to the ticket editor and setting it through that, you can view how the WP User integration add-on does this here:

https://github.com/eventespresso/eea-wpuser-integration/blob/master/EED_WP_Users_Admin.module.php#L1070

Outputting that price on the ticket selector isn’t going to be straightforward depending on where you want to output the price.

May I ask what output you are looking for?

You must be logged in to reply to this support post. Sign In or Register for an Account

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3 Documentation for Event Espresso 4

Status: publish

Updated by  Tony 2 months, 2 weeks ago ago

Topic Tags

Notifications

This topic is: not resolved
Do NOT follow this link or you will be banned from the site!