Share EfnWeb, LLC

Facebook MySpace Twitter Digg Delicious Stumbleupon Google Bookmarks 
PHP - CSS enhancement PDF Print E-mail
Simple PHP-CSS enhancement
(Figure 1)

Client requested that the Shipping Method on his invoices be highlighted whenever a customer wants something other than Ground Shipping. The order total information (Figure 2) are array items. The application simply displays an 'order total' array via a loop.

To highlight only one of the array items presented a problem that I solved as follows:

  1. Added a CSS ID that increments a number value at the end of its name as the program loops through the order totals array, i.e. '#OrderTotalsTitle' . $i (0, 1, 2, and so on).
  2. Through an embedded CSS, set a yellow background color to the CSS id number that corresponds to the array item number for Shipping Method.
  3. Write a conditional that displays the embedded CSS only when something other than Ground Shipping is the shipping method.
  4. The Order Total can include a Coupon Code, at which times the Shipping Method's array item number is offset by 1 location. Write a conditional that accounts for Coupon Codes. Since the Coupon Codes can be of any length combination of alpha numeric characters, the script looks for the Coupon Code via regular expressions. The output is shown in Figure 2 with a sample Order Total result that uses a coupon and a shipping method other than Ground Service.

Simple PHP/CSS order total enhancement
(Figure 2)