Jump to content

alien73

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

alien73's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I'm building a Cart and have 7 forms all are the same just the form field names differ. Paypal allows up to 7 starting with on0 os0 then on1 os1 then on2 os2 etc. If I add all 7 the code would be huge. Wondering a switch/ case would work? Here's the first option/attribute/price form. // Begin Option/Attributes/Prices 1. if (!empty($opt1)) { $output .= '<input type="hidden" name="on0" value="'. $node->ps_product_options1 .'" />'; $output .= '<br /><br />'; $output .= 'Select Option: <strong> '. ucwords($node->ps_product_options1) .'</strong> <br />'; $output .= '<select name="os0">'; $output .= '<option value="Select a '. $node->ps_product_options1 .'">'; $output .= '-- Select a '. ucwords($node->ps_product_options1) .' --</option>'; // Retrieve options/attributes/prices preg_match_all("/[-|+]\s\d+\.\d{2}/", $attrp1, $matches1); for($i=0;$i<count($otp1_pieces);$i++) { $parts1 = explode(" ", $matches1[0][$i]); // If attribute prices are left blank add default if ($parts1[1] == '') { eval ('$get_prices1 = $node->ps_sell_price ' . $parts1[0] . '- 0.00;'); } else { // Show New Price to pass to Paypal's Cart if ($node->ps_check_sale_price == 0) { eval ('$get_prices1 = $node->ps_sell_price ' . $parts1[0] . ' $parts1[1];'); } else { eval ('$get_prices1 = $node->ps_sale_price ' . $parts1[0] . ' $parts1[1];'); } } $output .= '<option value="'. ucwords($otp1_pieces[$i]) .'"> '. ucwords($otp1_pieces[$i]) .''; $output .= ' '. t('(') .''. curr() .''.number_format($get_prices1, 2) .''. t(')') .' '. showcurrency_abbr() .'</option>'; } // Pass Attribute Prices to Paypal $output .= '<input type="hidden" name="option_index" value="0" />'; for($i=0;$i<count($otp1_pieces);$i++) { $parts1 = explode(" ", $matches1[0][$i]); if ($parts1[1] == '') { // If attribute prices are left blank add default value eval ('$get_prices1 = $node->ps_sell_price ' . $parts1[0] . '+ 0.00;'); } else { // Use Sell or Sale Price if ($node->ps_check_sale_price == 0) { eval ('$get_prices1 = $node->ps_sell_price ' . $parts1[0] . ' $parts1[1];'); } else { eval ('$get_prices1 = $node->ps_sale_price ' . $parts1[0] . ' $parts1[1];'); } } $output .= '<input type="hidden" name="option_select'. $i .'" value="'. ucwords($otp1_pieces[$i]) .'" />'; $output .= '<input type="hidden" name="option_amount'. $i .'" value="'. number_format($get_prices1, 2) .'" />'; } } // End Option/Attributes/Prices 1.
  2. Thanks, but it doesn't work perhaps it's because it's not checking for a space after the - or + sign? Not sure? Sorry for got to mention that.. oops I have a text box and I want preg_match_all to check for the - or + sign then a space then the price. I'm setting up a down and dirty product options with prices feature - 5.00 + 25.00 +105.00 etc...
  3. Hi there, How would I change the reg expressions to allow any number format like 1.23 10.23 100.23 1000.23 Right now I have the code to match a ( - or +) then a number, digit then 2 numbers. preg_match_all("/[-|+]\s\d{1}\.\d{2}/", $sym_price, $matches); Thanks in advance
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.