Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Feb 2005
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Php code removing slashes from url form?

    I am using a cart,
    added a variation to the product and it is removing slashes from the field. I need it to keep slashes since the user will need to input a url.

    you can test it here.
    http://www.arcperformance.com/sourcefans/usa-fans/
    Click add to cart, then type in a url in the cart page. and it strips the slash.

    The code i believe to be the issue is the following

    Code:
    public function setCustomFieldInfo($info) {
        $info = $info;
        $this->_customFieldInfo = $info;
      }
      
      public function getQuantity() {
        return $this->_quantity;
      }
      
      public function getCustomField($itemIndex, $fullMode=true) {
        $out = '';
        if($this->_productId > 0) {
          $p = new Cart66Product();
          $p->load($this->_productId);
          
          if($p->custom == 'single') {
            $desc = $p->custom_desc;
            $value = $this->_customFieldInfo;
            if($fullMode) {
              $buttonValue = empty($value) ? 'Save' : 'Update';
              $showCustomForm = empty($value) ? '' : 'none';
              $change = empty($value) ? '' : "<a href='' onclick='' id='change_$itemIndex'>Change</a>";
              $out = "
              <script type='text/javascript'>
                (function($){
                  $(document).ready(function(){
                    $('#change_$itemIndex').click(function() {
                		  $('#customForm_$itemIndex').toggle();
                		  return false;
                		});
                  })
                })(jQuery);
              </script>
              <br/><p class=\"Cart66CustomFieldDesc\">$desc:<br/><strong>$value</strong> $change</p>
              <div id='customForm_$itemIndex' style='display: $showCustomForm;'>
              <input type=\"text\" name=\"customFieldInfo[$itemIndex]\" value=\"$value\" class=\"Cart66CustomTextField\" id=\"custom_field_info_$itemIndex\" />
              <input type=\"submit\" value=\"$buttonValue\" /></div>";
            }
            else {
              if(empty($value)) {
                $cartPage = get_page_by_path('store/cart');
                $viewCartLink = get_permalink($cartPage->ID);
                $value = "<a href='$viewCartLink'>Click here to enter your information</a>";
              }
              $out = "<br/><p class=\"Cart66CustomFieldDesc\">$desc:<br/><strong>$value</strong></p>";
              
            }
          }
          elseif($p->custom == 'multi') {
            $desc = $p->custom_desc;
            $value = $this->_customFieldInfo;
            if($fullMode) {
              $buttonValue = empty($value) ? 'Save' : 'Update';
              $showCustomForm = empty($value) ? '' : 'none';
              $change = empty($value) ? '' : "<a href='' onclick='' id='change_$itemIndex'>Change</a>";
              $brValue = nl2br($value);
              $out = "
              <script type='text/javascript'>
                (function($){
                  $(document).ready(function(){
                    $('#change_$itemIndex').click(function() {
                		  $('#customForm_$itemIndex').toggle();
                		  return false;
                		});
                  })
                })(jQuery);
              </script> 
              <br/><p class=\"Cart66CustomFieldDesc\">$desc:<br/><strong>$brValue</strong><br/>$change</p>
              <div id='customForm_$itemIndex' style='display: $showCustomForm;'>
              <textarea name=\"customFieldInfo[$itemIndex]\" class=\"Cart66CustomTextarea\" id=\"custom_field_info_$itemIndex\" />$value</textarea>
              <br/><input type=\"submit\" value=\"$buttonValue\" /></div>";
            }
            else {
              if(empty($value)) {
                $cartPage = get_page_by_path('store/cart');
                $viewCartLink = get_permalink($cartPage->ID);
                $value = "<a href='$viewCartLink'>Click here to enter your information</a>";
              }
              $value = nl2br($value);
              $out = "<br/><p class=\"Cart66CustomFieldDesc\">$desc:<br/><strong>$value</strong></p>";
            }
          }
        }
        return $out;
      }
      
      /**
       * Return the value of the custom field info or false if the value is empty
       */
      public function getCustomFieldInfo() {
        $info = false;
        if(!empty($this->_customFieldInfo)) {
          $info = $this->_customFieldInfo;
        }
        return $info;
      }
      
      /**
       * Return the value of the custom field description or false if the value is empty
       */
      public function getCustomFieldDesc() {
        $desc = false;
        if($this->_productId > 0) {
          $p = new Cart66Product();
          $p->load($this->_productId);
          if(strlen($p->custom_desc) > 0) {
            $desc = $p->custom_desc;
          }
        }
        return $desc;
      }
    
    :D Thanks for the help!!!!!!

  • #2
    New to the CF scene
    Join Date
    Jan 2012
    Location
    Belgrade, Serbia
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    addslashes

    Maybe try addslashes() function?

    $urlLink = '<a href.../..

    $fixedUrlLink = addslashes($urlLink);


    Can't find the cart on your site to test....

  • #3
    New Coder
    Join Date
    Feb 2005
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts
    http://www.arcperformance.com/sourcefans/usa-fans/
    there is small text to add item to cart


    then the cart is here

    http://www.arcperformance.com/sourcefans/store/cart/

    that is where the link goes.

  • #4
    New Coder
    Join Date
    Feb 2005
    Posts
    63
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Any ideas?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •