Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8158227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:32:26+00:00 2026-06-06T17:32:26+00:00

I have order confirmation html emails being parsed by a PHP script. The script

  • 0

I have order confirmation html emails being parsed by a PHP script. The script does a few things successfully but I can’t work out how to get it to search through the email for all product prices, and then to set a flag if the value is greater than £500.

Basically, I’d like the script to send me an email alert if an order is over £500.

Below is what I have so far. $body is the content of the HTML email. I know that part works as the other rules are setup fine. I think my problem is the $pattern rules for preg_match – I don’t think it’s identifying the price values correctly.

Is there a way I can search $body for anything with the format of £xx.xx (where each x is a number) and add 1 to $temp for each value it finds that is greater than £500? I can’t work this out…

if (stristr($body,'Order Confirmation') !== false) {

    $string = $body;

    $pattern = '/^[0-9]{1,}$/';

    preg_match ($pattern, $string, $matches);

    $temp =  array_filter($matches, function($value) {
        return $value >= 500;
    });

if ($temp >= 1)
{
    $headers = "Content-type: text/html \r\n";
    $headers .= "From: Robot<robot@robot.com>";
    mail('joe@blogs.com','Internet Order Value Over £500', $body, $headers);
}

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T17:32:28+00:00Added an answer on June 6, 2026 at 5:32 pm

    I think this will do what you want. the code should work if you copy-and-paste into a file with a php extension. You’ll have to edit it slightly for your script.

    <html>
    
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link rel="stylesheet" media="screen" href="bla.css" >
        <script type="text/javascript" src="https:ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    </head>
    
    <body>
    
    <?php
    
    $string = "lots of things here oh look a price in bold <b>£656.00</b> then more things oh wow";
    
    $pattern = '~<b>£([^<]*).([^<]*)</b>~'; //pattern to find the price in-between the <b></b> tags in $string
    
    preg_match ($pattern, $string, $matches);
    
    $price = substr($matches[0],5); // removes the <b>£ bits from the match if present
    
    if ($price >= 500.00) // if statement to determine if greater than a value
    {
    echo "value is greater than £500";
        }
    
    ?>
    
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried desperately to modify the default charset for order confirmation emails to
So I have the following JSON that is being displayed on an order confirmation
I have recently tried to use the php mail function to send out confirmation
I've added the following code to the Magento 1.5.1 order confirmation page (success.phtml): <?php
Firstly I would like confirmation that I have understood NSCopying correctly ... In order
I have an HTML order form that collects info and then on submission passes
Lets say I have data in two tables. In one I have Order ID
I have an order-statistic augmented red black tree. it works for the most part.
I have an Order model, which has_many payments and a checkout Controller. The Controller
I have to order a list of child entities by dates. Right now I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.