Advertisement
maxhodges0

transactionchoice

Sep 10th, 2012
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.30 KB | None | 0 0
  1. $inquire_button_alternative_text = get_post_meta($post->ID, "inquire_button_alternative_text", true);
  2.  
  3. if (empty($inquire_button_alternative_text)) {
  4. //make a 'get a quote link'
  5.  
  6.     $nonce = wp_create_nonce($post->ID);
  7.     // Store the current product information into temporarly for later use
  8.     if (!isset($_SESSION['current_product']))
  9.         {
  10.             $_SESSION['current_product'] = array();
  11.         }
  12.         $_SESSION['current_product'][$nonce] = array(
  13.             'link' => get_permalink($post->ID),
  14.             'title' => get_the_title()
  15.             );
  16.  ?>
  17. <div class="left"><a href="<?php echo home_url().'?nonce='.$nonce; ?>">Get a quote</a></div>
  18.  
  19. <?php } elseif(strpos($inquire_button_alternative_text, "shop.whiterabbitjapan")) {
  20.     // make a buy now link
  21.  
  22.         define('REGEX_URL','/http\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/');
  23.         define('REGEX_URLS','/https\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/');
  24.         if(preg_match(REGEX_URL, $inquire_button_alternative_text, $url) || preg_match(REGEX_URLS, $inquire_button_alternative_text, $url)) {
  25.             ?>
  26.             <div class="left">
  27.             <?php if (isset($_SESSION['partner']) && !empty($_SESSION['partner'])) {
  28.             $url[0] = add_query_arg( 'a_aid', $_SESSION['partner'],$url[0]);
  29.             }?>
  30.             <a href="<?php echo $url[0]; ?>" target="_blank">Buy from our shop</a>
  31.             </div>        
  32.         <?php }
  33.         }
  34. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement