Community Support Forums — WordPress® ( Users Helping Users ) — 2012-01-26T12:45:53-05:00 http://www.primothemes.com/forums/feed.php?f=4&t=16906 2012-01-26T12:45:53-05:00 http://www.primothemes.com/forums/viewtopic.php?t=16906&p=61640#p61640 <![CDATA[Re: Variables Not Interpreted Correctly in Custom Value]]>
Code:
$button = do_shortcode('[s2Member-PayPal-Button level="1" ccaps="" desc="Shared Plan B" ps="paypal" lc="" cc="USD" dg="0" ns="1" custom="example.com|$fn|$email|$domain|$package|$pay|$oid|$lang" ta="0" tp="0" tt="D" ra="87.45" rp="1" rt="Y" rr="1" rrt="" rra="1" image="default" output="button" /]'); 


In the above code example, $email will not be treated as a variable by PHP because it's enclosed within the single quotes of the do_shortcode() function.

For example,

Code:
$first = "Raam"
$last = "Dev"
echo "Hello $first $last"; // outputs Hello Raam Dev
echo 'Hello $first $last'; // outputs Hello $first $last
echo 'Hello first name ' . $first . ' and last name ' . $last . '!'; // outputs Hello first name Raam and last name Dev!
 


For PHP to treat $first as a variable, it must exist between double-quotes, not single-quotes (or it must exist outside of the quotes). Please see PHP Variable Basics for more info.

In your do_shortcode() function, you can close and open your single quotes to have PHP translate the variables that need to be translated:

Code:
$button = do_shortcode('[s2Member-PayPal-Button level="1" ccaps="" desc="Shared Plan B" ps="paypal" lc="" cc="USD" dg="0" ns="1" custom="example.com|' . $fn . '|' . $email . '|' . $domain . '|' . $package . '|' . $pay . '|' . $oid . '|' . $lang . '" ta="0" tp="0" tt="D" ra="87.45" rp="1" rt="Y" rr="1" rrt="" rra="1" image="default" output="button" /]'); 

Statistics: Posted by Raam Dev — January 26th, 2012, 12:45 pm


]]>
2012-01-25T10:33:17-05:00 http://www.primothemes.com/forums/viewtopic.php?t=16906&p=61533#p61533 <![CDATA[Re: Variables Not Interpreted Correctly in Custom Value]]> - I set up the buttons matching all the options
- I use _GET to obtain the option settings
- then I use do_shortcode to make the shortcode available

The only culprit I can think of is because I'm doing all of these inside a shortcode function (which is placed on the membership options page). This is my code:
Code:
function confirm_func ($atts) {
   $fn = $_GET['fn'];
   $email = $_GET['email'];
   $domain = $_GET['domain'];
   $package = $_GET['package'];
   $pay = $_GET['pay'];
   $oid = $_GET['oid'];
   $lang = $_GET['lang'];

   if ($pay == 'alipay') {
      switch($package) {
         case 'A':
            $button = do_shortcode('[s2Member-Pro-AliPay-Button level="1" ccaps="" desc="托管套餐A" custom="example.com|" . $fn . "|" . $email . "|" . $domain . "|" . $package . "|" . $pay . "|" . $oid . "|" . $lang ra="550" rp="1" rt="Y" image="default" output="anchor" /]');
            $pack = '托管套餐A';
            break;
         case 'B':
            $button = do_shortcode('[s2Member-Pro-AliPay-Button level="1" ccaps="" desc="托管套餐B" custom="example.com|$fn|$email|$domain|$package|$pay|$oid|$lang" ra="700" rp="1" rt="Y" image="default" output="anchor" /]');
            $pack = '托管套餐B';
            break;
         case 'C':
            $button = do_shortcode('[s2Member-Pro-AliPay-Button level="1" ccaps="" desc="无限托管" custom="example.com|$fn|$email|$domain|$package|$pay|$oid|$lang" ra="999" rp="1" rt="Y" image="default" output="anchor" /]');
            $pack = '无限托管';
            break;
         default:
            $output .= '出错了!';
      }
   } else if ($pay == 'paypal') {
      switch($package) {
         case 'A':
            $button = do_shortcode('[s2Member-PayPal-Button level="1" ccaps="" desc="Shared Plan A" ps="paypal" lc="" cc="USD" dg="0" ns="1" custom="example.com|$fn|$email|$domain|$package|$pay|$oid|$lang" ta="0" tp="0" tt="D" ra="65.45" rp="1" rt="Y" rr="1" rrt="" rra="1" image="default" output="button" /]');
            $pack = 'Shared Plan A';
            break;
         case 'B':
            $button = do_shortcode('[s2Member-PayPal-Button level="1" ccaps="" desc="Shared Plan B" ps="paypal" lc="" cc="USD" dg="0" ns="1" custom="example.com|$fn|$email|$domain|$package|$pay|$oid|$lang" ta="0" tp="0" tt="D" ra="87.45" rp="1" rt="Y" rr="1" rrt="" rra="1" image="default" output="button" /]');
            $pack = 'Shared Plan B';
            break;
         case 'C':
            $button = do_shortcode('[s2Member-PayPal-Button level="1" ccaps="" desc="Unlimited Hosting" ps="paypal" lc="" cc="USD" dg="0" ns="1" custom="example.com|$fn|$email|$domain|$package|$pay|$oid|$lang" ta="0" tp="0" tt="D" ra="107.25" rp="1" rt="Y" rr="1" rrt="" rra="1" image="default" output="button" /]');
            $pack = 'Unlimited Hosting';
            break;
         default:
            $output .= 'Package and Gateway Information Missing. Contact Support';
      }
   }


   if (strpos($_SERVER['REQUEST_URI'], '/zh/') !== false) {
      $output .= '<table><tbody>';
      $output .= '<tr><td>用户ID</td><td>' . $oid . '</td></tr>';
      $output .= '<tr><td>语言</td><td>中文</td></tr>';
      $output .= '<tr><td>套餐</td><td>' . $pack . '</td></tr>';
      $output .= '<tr><td>结算</td><td>' . $button . ' </td></tr>';
      $output .= '</tbody></table>';
   } else {
      $output .= '<table><tbody>';
      $output .= '<tr><td>OID</td><td>' . $oid . '</td></tr>';
      $output .= '<tr><td>Language</td><td>English</td></tr>';
      $output .= '<tr><td>Hosting Plan</td><td>' . $pack . '</td></tr>';
      $output .= '<tr><td>Purchase</td><td>' . $button . '</td></tr>';
      $output .= '</tbody></table>';
   }

   return $output;
}
add_shortcode('confirm', 'confirm_func');


You can see that I tried 2 approaches in putting that data into the button. One is "custom="example.com|" . $fn . "|" . $email . "|" . $domain . "|" . $package . "|" . $pay . "|" . $oid . "|" . $lang" and the other is "custom=example.com|$fn|$email|$domain|$package|$pay|$oid|$lang". Unfortunately, none of them works.
In the first approach, my button link look something like this
Code:
https://www.alipay.com/cooperate/gateway.do?_input_charset=utf-8&body=托管套餐A&extra_common_param=example.com%7C&notify_url=http%3A%2F%2Fexample.com%2F&out_trade_no=4f201de64f3c7%7E1%3A%3A1+Y%7E1%7E120.32.3.116&partner=2088501820003753&payment_type=1&paymethod=directPay&return_url=http%3A%2F%2Fexample.com%2F%3Fs2member_pro_alipay_return%3D1&seller_email=zling%40example.com&service=create_direct_pay_by_user&show_url=http%3A%2F%2Fexample.com%2F&subject=example.com&total_fee=550&sign=0f0b6a44834ed2838ee0e98d91a2928f&sign_type=MD5
Basically, the variables aren't even included

In the second approach, all the variable turned into their literal value:
Code:
https://www.alipay.com/cooperate/gateway.do?_input_charset=utf-8&body=托管套餐B&extra_common_param=example.com%7C%24name%7C%24email%7C%24domain%7C%24package%7C%24pay%7C%24oid%7C%24lang&notify_url=http%3A%2F%2Fexample.com%2F&out_trade_no=4f201e75977fa%7E1%3A%3A1+Y%7E1%7E120.32.3.116&partner=2088501820003753&payment_type=1&paymethod=directPay&return_url=http%3A%2F%2Fexample.com%2F%3Fs2member_pro_alipay_return%3D1&seller_email=zling%40example.com&service=create_direct_pay_by_user&show_url=http%3A%2F%2Fexample.com%2F&subject=example.com&total_fee=700&sign=1bcf9786e7ab10434384fd021a160651&sign_type=MD5

Statistics: Posted by angelazou — January 25th, 2012, 10:33 am


]]>
2012-01-19T23:12:58-05:00 http://www.primothemes.com/forums/viewtopic.php?t=16906&p=61062#p61062 <![CDATA[Re: Variables Not Interpreted Correctly in Custom Value]]>
Code:
$pay = $_GET["pay"];
if ($pay == "alipay") {
  $button = [s2Member-Pro-AliPay-Button level="1" ccaps="" desc="A" custom="domain.com|1|$pay|$package|$lang|$email|$pass" ra="550" rp="1" rt="Y" image="default" output="anchor" /]
}

return $button;


There are some issues at the site presently, once it's fixed, I can show you the entire shortcode I used. But I can be very sure that it was running within a PHP environment. I will check out that thread, and see if it can fix the issue.

Statistics: Posted by angelazou — January 19th, 2012, 11:12 pm


]]>
2012-01-19T22:50:29-05:00 http://www.primothemes.com/forums/viewtopic.php?t=16906&p=61052#p61052 <![CDATA[Re: Variables Not Interpreted Correctly in Custom Value]]> Hi there. Thanks for your inquiry.
These variables are not being parsed because they are not wrapped inside PHP tags.
custom="domain.com|1|$pay|$package|$lang|$email|$pass"
In addition, I'm not sure where the value of these variables come from exactly? I'm assuming that you do though. You might take a look at this post for some clarity in this matter. Please note that you might need to seek assistance from a PHP developer to accomplish what you need here.

See: viewtopic.php?f=36&t=1604

Statistics: Posted by Jason Caldwell — January 19th, 2012, 10:50 pm


]]>
2012-01-19T20:31:03-05:00 http://www.primothemes.com/forums/viewtopic.php?t=16906&p=61032#p61032 <![CDATA[Re: Variables Not Interpreted Correctly in Custom Value]]> Statistics: Posted by angelazou — January 19th, 2012, 8:31 pm


]]>
2012-01-17T23:03:08-05:00 http://www.primothemes.com/forums/viewtopic.php?t=16906&p=60870#p60870 <![CDATA[Re: Variables Not Interpreted Correctly in Custom Value]]> Statistics: Posted by angelazou — January 17th, 2012, 11:03 pm


]]>
2012-01-17T03:58:24-05:00 http://www.primothemes.com/forums/viewtopic.php?t=16906&p=60799#p60799 <![CDATA[[Solved] Variables Not Interpreted Correctly in Custom Value]]>
Code:
[s2Member-Pro-AliPay-Button level="1" ccaps="" desc="A" custom="domain.com|1|$pay|$package|$lang|$email|$pass" ra="550" rp="1" rt="Y" image="default" output="anchor" /]


I tried to use the above code, but all I get in the Alipay button is their literal value

Code:
extra_common_param=domain.com%7C1%7C%24pay%7C%24package%7C%24lang%7C%24email%7C%24pass


Must the attribute values be literal? I really need to save these information dynamically (as I pull them from the form), and custom field is the only way I can do this without too much tweaking (if possible, I'd really prefer not to create and dynamically popular a Pro Form). Where did I go wrong?

Angela

PS: In addition, if the variable contains HTML decoded entities such as %40 (which was originally the @ symbol), would S2member take care of that, or what is the function I should use to get it back to its original value?

Statistics: Posted by angelazou — January 17th, 2012, 3:58 am


]]>