Пример #1
0
 /**
  * Obtain the single instance of this OSCommerce install.
  */
 public static function instance()
 {
     if (!OSCommerce::$instance) {
         OSCommerce::$instance = new OSCommerce();
     }
     return OSCommerce::$instance;
 }
Пример #2
0
// Don't let osCommerce block the datafeed POST
require_once 'config.php';
require_once 'class.rc4crypt.php';
require_once 'class.xmlparser.php';
require_once 'oscommerce.class.php';
$_POST['FoxyData'] or die("error");
// Make sure we got passed some FoxyData
function fatal_error_handler($errno, $errstr, $errfile, $errline, $errcontext)
{
    if ($errno < E_WARN) {
        die($errstr);
    }
    return true;
}
set_error_handler('fatal_error_handler');
$osc = OSCommerce::instance();
/**
 * Utilities for reading and parsing the FoxyCart data feed and moving data
 *  to osCommerce.
 */
class FoxydataUtils
{
    /**
     * @param $osc    An instance of an OSCommerce class; used for doing
     *                address zone and country code lookups.
     */
    public function __construct($osc)
    {
        $this->osc = $osc;
    }
    /**
Пример #3
0
/**
 * Create a form for the send-off to FoxyCart based on the current osCommerce
 *  cart contents.  Not strictly necessary -- we could just send an aggregate
 *  total and weight -- but this way, the customers see what they're buying
 *  and that's just foxy.
 */
function getFoxyForm()
{
    global $customer_id;
    $osc = OSCommerce::instance();
    $cart = $osc->loadCartForCustomer(array('customers_id' => $customer_id));
    ob_start();
    ?>
  <form action="<?php 
    echo FOXYCART_CART_URL;
    ?>
" method="POST">
<?php 
    $ndx = 0;
    foreach ($cart as $product) {
        $fieldPrefix = $ndx++ > 0 ? $ndx . ':' : '';
        $freeShipping = defined('USE_FREE_SHIPPING') && $product['weight'] == 0;
        $category = $freeShipping ? PRODUCT_FREE_SHIPPING_CATEGORY : PRODUCT_CATEGORY;
        ?>
<input type="hidden" name="<?php 
        echo $fieldPrefix;
        ?>
code" value="<?php 
        echo htmlentities($product['id']);
        ?>
"/>
<input type="hidden" name="<?php 
        echo $fieldPrefix;
        ?>
name" value="<?php 
        echo htmlentities($product['name']);
        ?>
"/>
<input type="hidden" name="<?php 
        echo $fieldPrefix;
        ?>
price" value="<?php 
        echo htmlentities($product['final_price']);
        ?>
"/>
<input type="hidden" name="<?php 
        echo $fieldPrefix;
        ?>
weight" value="<?php 
        echo htmlentities($product['weight']);
        ?>
"/>
<input type="hidden" name="<?php 
        echo $fieldPrefix;
        ?>
quantity" value="<?php 
        echo htmlentities($product['quantity']);
        ?>
"/>
<input type="hidden" name="<?php 
        echo $fieldPrefix;
        ?>
category" value="<?php 
        echo htmlentities($category);
        ?>
"/>
<?php 
    }
    ?>
    <input type="hidden" name="h:basket" value="<?php 
    echo $osc->saveCartToString($cart);
    ?>
"/>
    <input type="hidden" name="h:sessionID" value="<?php 
    echo session_id();
    ?>
"/>
    <input type="hidden" name="empty" value="true"/>
    <input type="hidden" name="cart" value="checkout"/>
    <input type="submit" name="x:submit"/>
  </form>';
<?php 
    return ob_get_clean();
}