Results 1 to 5 of 5

Threaded View

  1. #1
    Join Date
    Nov 2007
    Location
    Essex, UK
    Posts
    137
    Plugin Contributions
    1

    Default Shopping cart coding problem with my payment module

    Hi, I have some code that should send the details of the shopping cart to sagepay/protx when an order is made, but I have found that when it is enabled you are unable to confirm the order as the button dissappers and so does the secruity cert for the site.

    It kind of acts like the coding stops the footer from working. If anyone can look at the code and find the problem it would be a great help.

    Code:
    function getShoppingCartInfo()
        {
            global $cart, $order;
    
       		$retStr = "";
    
            if (MODULE_PAYMENT_PROTX_SHOPCART == 'true') {
    		$shipping = $order->info['shipping_cost'];
    		$shipping = number_format($shipping, 2, '.', '');
     		$products = $cart->get_products();
    		$no_lines = sizeof($products);
    		$no_lines = $no_lines + 1;
    
    		$shippingStr .= ":Shipping:1:".$shipping.":----:".$shipping.":".$shipping;
    		$basketStr = "Basket=".$no_lines;
    		$moreStr .= ":More products...See Order.:1:----:----:----:----";
            $moreLen = strlen( $moreStr );
    		/*
    		      Maxmium size of the basket field according to SAGEPAY Form Documentation V2.22
    		      is 7500 characters. Allowing 7495 as a small safety net.
    		*/
    		$charCount = 7495 - strlen( $shippingStr ) - strlen( $basketStr );
    
    		$detail = "";
            $linesAdded = 0;
            $i = 0;
            $n=sizeof($products);
            $finished = false;
    
        	while ( ( $i<$n ) && ( !$finished ) ) {
       				$desc = $products[$i]['name'];
    				$desc  = str_replace(":", "", $desc);
    				$qty = $products[$i]['quantity'];
    				$price = $products[$i]['price'] + $cart->attributes_price($products[$i]['id']);
    				$tax = $price/100 * zen_get_tax_rate($products[$i]['tax_class_id']);
    				$tax = number_format($tax, 2, '.', '');
    				$finalPrice = $price + $tax;
    				$finalPrice = number_format($finalPrice, 2, '.', '');
    				$lineTotal = $qty * $finalPrice;
    				$lineTotal = number_format($lineTotal, 2, '.', '');
    				$line = ":".$desc.":".$qty.":".$price.":".$tax.":".$finalPrice.":".$lineTotal;
    				$line = str_replace("\n", "", $line);
    		        $line = str_replace("\r", "", $line);
    		        $len = strlen( $line );
    		        if ( ( $charCount - $moreLen - $len) > 0 ) {
    		            $linesAdded ++;
    		            $charCount -= $len;
    		            $detail .= $line;
    		        } else if ( $charCount - $moreLen > 0 ) {
    		            $detail .= $moreStr;
    		            $charCount -= $len;
    		            $linesAdded ++;
    		            $finished = true;
    		        }
    		        else {
    		            // We should not hit this point, but if we do lets fininsh
    		            $finished = true;
    		        }
    		        $i++;
       		}
    
       		if ( strlen( $detail ) > 0 )
       		{
       		    $linesAdded ++;
       		    $retStr = "&" . "Basket=" . $linesAdded . $detail . $shippingStr;
       		}
          }
          return $retStr;
        }
    Whoops nearly forgot to say im using zen-cart v1.3.8a
    Last edited by Nixak; 20 Jul 2009 at 06:03 PM. Reason: including zen cart version no.

 

 

Similar Threads

  1. Need simple coding help for Shopping Cart in Header
    By georgiepants in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 14 Apr 2010, 03:25 AM
  2. Problem with payment Module
    By alexipr in forum Addon Payment Modules
    Replies: 1
    Last Post: 9 Dec 2009, 11:17 PM
  3. Problem with Payment Module
    By artistwantab in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 16 Nov 2008, 05:04 AM
  4. Where can i locate the shopping cart coding.
    By namae in forum General Questions
    Replies: 2
    Last Post: 30 Oct 2008, 05:19 PM
  5. shopping cart with non payment gateway
    By dellvostro in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 14 Oct 2008, 04:54 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR