Pricing of Pizza Half and Half

Ok, so we are going to need to strip the Metade…
Give me a sec.

Will try and generalize the script for any filtered tag, hold on…

1 Like

But…
OrderTagPrice should have a value no matter if it has metade or not metade in the name… I think we are still facing a bug here…

thanks!!

G.

Im sure i remember reading a reason somewhere.
This script im sorting will solve your issue either way :slight_smile:

1 Like

Try this for size :wink:

function filteredHalfPizzaTagPrice(tagName,tagValue) {
	var filterPrefixLength = tagName.length + 1;
	var fullTagLength = tagValue.length;
	var sliceLength = filterPrefixLength - fullTagLength;
	var slicedTagValue = tagValue.slice(sliceLength);
	var qry = "SELECT [Price]FROM [OrderTags]WHERE [Name] = '"+slicedTagValue+"' and [Filter] = '"+tagName+"'";
	var tagPrice = sql.Query(qry).First;
	return tagPrice
}

Call it with {CALL:HANDELER.filteredHalfPizzaTagPrice('[:OrderTagName]','[:OrderTagValue]')}

Where handler is obviously your chosen script handler.

And replace the [:OrderTagPrice] in the rule with the call.

Maybe we can ask @Emre (sorry to bother you) if we could access that value regarding if you filter it or not…

sounds logical to me… but perhaps I am wrong…

Thanks!!!

G.

For anyone else with similar need to get the price from a prefixed tag here is a general script

function prefixedTagPrice(tagName,tagValue) {
	var filterPrefixLength = tagName.length + 1;
	var fullTagLength = tagValue.length;
	var sliceLength = filterPrefixLength - fullTagLength;
	var slicedTagValue = tagValue.slice(sliceLength);
	var qry = "SELECT [Price]FROM [OrderTags]WHERE [Name] = '"+slicedTagValue+"' and [Filter] = '"+tagName+"'";
	var tagPrice = sql.Query(qry).First;
	return tagPrice
}

{CALL:HANDELER.prefixedTagPrice(’[:OrderTagName]’,’[:OrderTagValue]’)}

1 Like

Just tested myself and all works :slight_smile:

What would be interesting is if using this script and the update tag action we can backward force the tag to have a price.

@gerlandog I think the reason the tag doesn’t have a price (this is just thinking about it logically not from memory) is that there is no tag in the database which matched the tag value once the prefix is added.
Does that make sense?
The configured tag has a value of the topping name, the tag added has prefix of half so is then half topping name which doesn’t match the configured tag value…

but it should have… as a matter of fact… my tag has price… if the preffix was originally used to be NO or EXTRA or ADD… it should have a price…

well, I am not sure now… jajajajajjaja

we are now busy working… will try this script tomorrow… we will se if you are a nice coder or not… we will see… mmmmmmmmmm :slight_smile: LOL!!!

Thanks!!!

G.

1 Like

I’ve tested myself, if it doesn’t it’s user error :-p

Does my explanation make sence though, if it is an oversight by emre then sure he can sort it by reverse processing in the same way the splice does to check for price using unprefixed tag value if my thinking in the reason why is correct.

I think it might not get done as what your achieving is what tag category was implemented for, to group tags.

Prefix and price would be pointless unless you could set a Rate on the prefix, ie replace was -1 with was 1, no would be 0 etc so that the price of the tag was actually effected by the prefix selection.
Which actually might be an interesting idea.
@QMcKay and kendash, does that make sense? Do you think it has any value as a sugestion/request?

A prefix rate would allow us to then either counteract or ignore tag prices based on the selected prefix…

1 Like

well, you dont seem to be a proven coder… its not working for me… :frowning:

thanks!!

G.

tomorrow will try to figure out what went wrong…

1 Like

Hehe, what is happening?

Did you replace both instances of tag price? The constraint and the order price field?

sorry, did not understand…

This script calls the tag price from table.

The [:OrderTagPrice] tag isn’t working in the rule and are two instances of it, one in the constraint and one in the field of the update order action.

I changed it in the show message and i get a BLANK… just for testing did not change anything else

Show your updated order tagged event rule.

thanks!!!

G.

Ok think I know, what’s you filter on that set of tags, you half prefix also has size yer? Grande? Is the prefix just half without grande?

Uploading…

thanks!!!

G.