The Official Website of AgoraCart and Agora.cgi
AgoraCart.com Demos Download AgoraCart User Manuals & Wiki Gold Members Forum Go Gold Now! Gold Version Memberships

AgoraCart.com

About
Features
Download
Payment Gateways
Send a Donation
Founders Club
BLOG: News & Updates

Showcases & Demos

AgoraCart Demos
Shop Live Stores

Downloads & Add-ons

Gold Version Downloads
DBwizz Database Mgr.
AgoraCart.com Store

Help & Support

User Manuals
Gold Version Users Forum
Gold Version Chat
Tech Support
Certified Agora Pros
Certified Designers
Hire a Freelancer

Gold Version Members

Member Benefits
Join Today!
Gold Members Home
Gold Version Users Forum
Gold Version Chat Rooms
Gold Version Downloads

For Store Owners

Merchant Accounts
Cool Resources
Advertise Here
"Powered by" Logos
Web Hosting Search

Misc.

Contact Us
MEET's Talking Guide
The Ancient Greek Agora






AgoraCart Free User Forums

This is the official FAQ and Cool Tips guide For the AgoraCart shopping Cart software


Official Sponsors of the AgoraCart Project:

       


RegisterSearchFAQLog in
Reply to topic Page 1 of 1
Sniffing through shopping cart in YourPayConnect-orderform
Author Message
Reply with quote
Post Sniffing through shopping cart in YourPayConnect-orderform 
I had this in another post but didn't get a response for a while. It seems new threads get responses quicker so here goes. If you want to move this to my post that would be fine.

I need to loop through the cart contents in YourPayConnect-orderform.html and display some form boxes based on what the total shipping weight is in the cart. I tried to copy the code from the header file (this is in Agora4) and make appropriate changes, but I got the following error:

"We're sorry, an error has occured. Please hit the browser back button, change what was done in error, and try again."

The code starts and ends with <!--agorascript-pre{code}--> and, in the header file, displays a cart summary at the top of the page if there's items in the cart. I kept stripping down the code to see what was causing the error. I discovered that for some reason it won't let me declare local variables in that file, but I'm not sure why. The following test code causes the same error:

<!--agorascript-pre {
local ($count,$shipping)=0;
return "hello";
}-->

Do you know why this is happening?

Thanks

View user's profile Send private message
Reply with quote
Post  
You're not getting responses because none of us has an answer for you...


_________________
God Bless!
Bonnie - AgoraCart Moderator

Get a Gold Membership
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger ICQ Number
Reply with quote
Post  
so you're thinking that this code should work in that file? Would there be another way to go about accessing the cart?

View user's profile Send private message
Reply with quote
Post  
well it could be that the...
<!--agorascript-pre {
local ($count,$shipping)=0;
return "hello";
}-->
doesn't work because the shipping has either already run in a seperate function or it hasn't run yet. when working with gateways you have to run the sub function while the main function (shipping in this case) is being run or allow for what you want to do in the main function so you can call it later. becareful what you do though. the security of the cart is mostly in the checkout end of the cart and whatever you do there may jepordize security. admittedly the likelyhood of someone finding your store with a gateway with a particular problem would not be very high. but still, one never knows and if it is found out the end result would be so heart breaking you'll probably resort to digging ditches! Crying or Very sad

YourPayConnect-order_lib.pl

sub process_YourPayConnect_order - this could be the area you're looking for to script to. the while (<CART>) { is a good place to query the db for product specific information.

the location of the agorascript pre script is important for another reason. i am assuming the "return" means print in which case the data being returned wont display unless the code is placed in a display area.
so if coding in a non-display area of the script you don't need agorascript you need to allow for the return of some particular data which you would call later in a diplay area.
good luck
d

Reply with quote
Post  
Thanks. That makes sense. I'll see what I can do.

View user's profile Send private message
Reply with quote
Post  
depending on what you need to do you may find it easier to add the script to the order_lib file or even the shipping file itself.
if you know how to do codehooks then you can probably attach the script using an appropriate codehook and either place it in the freeform logic or in the custom folder as a lib file.
d

Reply with quote
Post  
I've done what I need to do by changing the code directly rather than adding code hooks. My only concern is security.

I've added a field in the checkout form which asks for a pickup date (if the customer orders an item that we can't ship). I don't validate the date and it's not even required. I then include the date in the order and confirmation emails. Since I don't validate it, does that pose a security risk? If so, what's the easiest way to solve the problem?

Thanks

Here's the store:
www.kauffmansfruitfarm.com/cgi-bin/store/agora.cgi

View user's profile Send private message
Reply with quote
Post  
If you are just adding a field to the form, and it's not confidential info like credit card number, social security number, then, no, it does not cause a problem with security.

Is the field's display being based on the weight of the cart, did you figure that out?
That was what your original post in this thread was asking...


_________________
God Bless!
Bonnie - AgoraCart Moderator

Get a Gold Membership
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger ICQ Number
Reply with quote
Post  
Yes. I look throught the cart for 0-weight items (which are not shippable). If I find one, I show the user field. If not, life goes on as usual.

Thanks for the reply

View user's profile Send private message
Reply with quote
Post  
Could you post the code you used? It could help others in the future.


_________________
God Bless!
Bonnie - AgoraCart Moderator

Get a Gold Membership
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger ICQ Number
Reply with quote
Post  
Don't know if this is the smoothest way or not (I'm sure there's better methods), but it works for me.

I added this code to the beginning of YourPayConnect_order_form_prep function in YourPayConnect-order_lib.pl to snif through the cart and look for the correct items
Code:

     $zero_shipping_items = 0;
   $total_shipping = 0;

   open (CART, "$sc_cart_path") ||
   &file_open_error("$sc_cart_path", "display_cart_contents", __FILE__, __LINE__);

   while (<CART>) {
     @cart_fields = split (/\|/, $_);
        if($cart_fields[6] == 0)
      {
         $zero_shipping_items++;
      }
      else
      {
         $total_shipping++;
      }
    }
   close(CART);

The following code was then added to the YourPayConnect-orderform.html to show the appropriate information and boxes. Note that if the cart has 0-weight items AND shippable items, both the pickup date box and the shipping method box show up. If only 0-weight items, I don't show the shipping method option. Also, I remove the Ecom_ShipTo_Method from the required fields in the order_lib file and add it in the orderform file if the customer needs to pick a shipping method.
Code:

<!--agorascript-pre {
   if($zero_shipping_items > 0)
   {
      return q~
      <tr>
      <td colspan=2 class="ac_checkout_top_col"><blockquote>
      <em><p>You have ordered one or more perishable items that we cannot ship.  These items have a shipping weight of 0 in the list above.</p>
      <p>You will need to pick up the items at our store in Bird-In-Hand.  Orders placed by 5:00 PM will be ready for pickup by 10:00 AM the following business morning.  If you prefer to pick up the item on a different day, please specify the pickup date below.</p><p>Please print your receipt after it is emailed to you and bring it as proof of purchase.</p></em></blockquote>
      </td>
      </tr>
      
      <tr>
      <td class="ac_checkout_left_col">Pickup Date:</td>
      <td class="ac_checkout_right_col"><INPUT TYPE=TEXT NAME="Ecom_Pickup_Date"
VALUE="$eform_Ecom_Pickup_Date" size=15></td>
      </tr><tr><td colspan=2>&nbsp</td></tr>~;
   }
}-->

<!--agorascript-pre {
   if($total_shipping > 0){

   push(@sc_order_form_required_fields,"Ecom_ShipTo_Method");      

   return q~<tr>
   <td colspan=2 class="ac_checkout_top_col">   
   Please select where your order will be shipped/billed
   </td>
   </tr>
   <tr>

   <TD class="ac_checkout_left_col">Shipping Method:</TD>
   <TD class="ac_checkout_right_col">

   <select name="Ecom_ShipTo_Method">
   <option value="$vform_Ecom_ShipTo_Method">Select Shipping Method</option
   <option value="Pickup">Pickup</option>
   <option value="UPS Ground (GND)">UPS Ground (7-10 days)</option>
   <option value="UPS 2nd Day Air (2DA)">UPS 2nd Day Air</option>
   <option value="UPS Next Day Air (1DA)">UPS Next Day Air</option>
   </select>

   </td>
   </TR>~;}
   else{
   return q~<tr>
   <td colspan=2 class="ac_checkout_top_col">   
   Please provide your billing information
   </td>
   </tr>
   <tr>~;}

}-->

The $zero_shipping_items variable didn't seem to persist throughout the checkout process, so I had to reconstruct it one more time for my validation emails. The following code was added to the process_YourPayConnect_order sub in the YourPayConnect-orderform_lib.pl file:

The code that used to look like this:
Code:

while (<CART>) {
  $cartData++;
  @cart_fields = split (/\|/, $_);
  $quantity = $cart_fields[0];
  $product_price = $cart_fields[3];
  $product = $cart_fields[4];
  $weight = $cart_fields[6];
  $options = $cart_fields[$cart{"options"}];
  $options =~ s/<br>//g;
  $text_of_cart .= &cart_textinfo(*cart_fields);
  $stevo_shipping_thing .= "|quantity\*$weight";
  $stevo_shipping_names .= "|$product\($options\)";
  &codehook("process-cart-item");
 }
close(CART);

now looks like this:
Code:

$zero_shipping_items = 0;

while (<CART>) {
  $cartData++;
  @cart_fields = split (/\|/, $_);
  $quantity = $cart_fields[0];
  $product_price = $cart_fields[3];
  $product = $cart_fields[4];
  $weight = $cart_fields[6];
   if($weight == 0)
   {
      $zero_shipping_items++;
   }
  $options = $cart_fields[$cart{"options"}];
  $options =~ s/<br>//g;
  $text_of_cart .= &cart_textinfo(*cart_fields);
  $stevo_shipping_thing .= "|quantity\*$weight";
  $stevo_shipping_names .= "|$product\($options\)";
  &codehook("process-cart-item");
 }
close(CART);

and I added this under the line that said $text_of_cart .= "SHIPPING INFORMATION --------------\n\n";
Code:

if($zero_shipping_items > 0)
{
   $text_of_cart .= "Pickup Date:   $eform_Ecom_Pickup_Date\n";
   $orderLoggingHash{'pickupDate'} = "$eform_Ecom_Pickup_Date";
   $text_of_confirm_email .= "FRUIT BASKET PICKUP DATE:   $eform_Ecom_Pickup_Date\n\n";
}

this adds the pickup date to the confirmation and order emails.

Like I said, this is kind of clunky and I'm sure it could be improved and slimmed down, but it works for me for now. Smile If you have suggestions I'd love to hear about them.

View user's profile Send private message
Display posts from previous:
Reply to topic Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum