This is not very simple. At the item scan event (Publix item), you would need to validate the scanned GTIN as a numeric value and do one of the following:
- Loop through all known GTINs to see if the scanned Publix item is one on promotion (more work on the server) OR
- Have a prepopulated list of Publix items on special that is read into memory at form-load and validate the value against those pre-read GTINs (more memory usage)
THEN you would need to loop through to look and see if one of the matching national-brand products was in the order and, if it is, deduct the value of the coupon. This is all assuming that the national brand item was scanned first. Obviously that doesn't always happen. To account for this, you must constantly be looping through the order looking for matching items or do it once at the "tender/total" event at the end of the order. Doing it at the end is better for processing/memory usage but an inconvenience for the customer because they can't see if the item's value was deducted or not.
Obviously there are 100 ways to accomplish the same thing in programming but this is just the simplest way I could think of. You are definitely talking about a large amount of code here.