...

View Full Version : Php code removing slashes from url form?



bigredkacy
01-21-2012, 07:50 AM
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


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!!!!!!

karlos81
01-21-2012, 09:17 AM
Maybe try addslashes() function?

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

$fixedUrlLink = addslashes($urlLink);


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

bigredkacy
01-21-2012, 09:01 PM
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.

bigredkacy
01-22-2012, 02:36 AM
Any ideas?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum