<?php

if (!defined('_VALID_MOS') && !defined('_JEXEC')) {
    die('Direct Access to ' . basename(__FILE__) . ' is not allowed.');
}
/**
* This is the default Basket Template. Modify as you like.
*
* @version $Id: basket.html.php 
* @package OPC
* @subpackage templates
* @copyright Copyright (C) 2004-2005 Soeren Eberhardt. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/
?>
<a href="#" <?php 
echo $onclick;
?>
><?php 
echo OPClang::_('COM_ONEPAGE_CLICK_HERE_TO_DISPLAY_SHIPPING');
?>
</a>
Example #2
0
 function getShipping(&$ref, &$cart, $ajax = false)
 {
     if (empty($cart)) {
         if (!empty($ref->cart)) {
             $cart =& $ref->cart;
         } else {
             $cart = VirtueMartCart::getCart(false, false);
         }
     }
     include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php';
     $cmd = JRequest::getVar('cmd', false);
     //$methods = OPCloader::getPluginMethods();
     if (!$ajax) {
         if (!class_exists('vmPSPlugin')) {
             require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php';
         }
         JPluginHelper::importPlugin('vmpayment');
         $dispatcher = JDispatcher::getInstance();
         if (!isset($cart)) {
             $cart = VirtueMartCart::getCart();
         }
         $plugins = array();
         $html = '';
         $results = $dispatcher->trigger('loadPluginJavascriptOPC', array(&$cart, &$plugins, &$html));
         //include(JPATH_SITE.DS.'components'.DS.'com_onepage'.DS.'helpers'.DS.'third_party'.DS.'third_party_shipping_javascript.php');
         if (!empty($html)) {
             OPCloader::$extrahtml .= $html;
         }
         unset($html);
         // so we don't update the address twice
         require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'controllers' . DS . 'opc.php';
         $c = new VirtueMartControllerOpc();
         $c->setAddress($cart, true, false, true);
     }
     if ($cmd != 'customershipping' && $cmd != 'runpay') {
         if (!empty($op_customer_shipping)) {
             $onclick = 'onclick="javascript: return Onepage.op_runSS(null, false, true, \'customershipping\');" ';
             $html = $this->fetch($ref, 'customer_shipping', array('onclick' => $onclick));
             if (empty($html)) {
                 $html = '<a href="#" ' . $onclick . '  >' . OPClang::_('COM_ONEPAGE_CLICK_HERE_TO_DISPLAY_SHIPPING') . '</a>';
             }
             $html .= '<input type="hidden" name="invalid_country" id="invalid_country" value="invalid_country" /><input type="hidden" name="virtuemart_shipmentmethod_id" checked="checked" id="shipment_id_0" value="choose_shipping" />';
             $shipping_choose_html = '<div id="customer_shipping_wrapper">' . $html . '</div>';
             $shipping_choose_html_a = array();
             $shipping_choose_html_a[] = $shipping_choose_html;
         }
     }
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'ajaxhelper.php';
     $bhelper = new basketHelper();
     if (!isset($shipping_choose_html_a)) {
         $sh = $bhelper->getShippingArrayHtml($ref, $cart, $ajax);
     } else {
         $sh = $shipping_choose_html_a;
     }
     if (empty($cart) || empty($cart->products)) {
         $op_disable_shipping = OPCloader::getShippingEnabled($cart);
         if (empty($op_disable_shipping)) {
             $html = '<input type="hidden" name="invalid_country" id="invalid_country" value="invalid_country" /><input type="hidden" name="virtuemart_shipmentmethod_id" checked="checked" id="shipment_id_0" value="choose_shipping" />';
         }
         $html .= '<div style="color: red; font-weight: bold;">' . OPCLang::_('COM_VIRTUEMART_EMPTY_CART') . '</div>';
         $sh = array($html);
     }
     if (!empty($disable_payment_per_shipping)) {
         $session = JFactory::getSession();
         $dpps = array();
         require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'transform.php';
         foreach ($sh as $k => $cs) {
             foreach ($dpps_search as $key => $val) {
                 // if we find the need in the shipping, let's associate it with an id
                 $val = urldecode($val);
                 if (strpos($cs, $val) !== false) {
                     //if (!empty($dpps[$key])) continue;
                     $id = OPCTransform::getFT($cs, 'input', 'virtuemart_shipmentmethod_id', 'name', 'virtuemart_shipmentmethod_id', '>', 'value');
                     if (is_array($id)) {
                         $id = reset($id);
                     }
                     if (empty($dpps[$key])) {
                         $dpps[$key] = array();
                     }
                     $dpps[$key][] = $id;
                 }
             }
         }
         $session->set('dpps', $dpps);
     }
     if ($cart->pricesUnformatted['billTotal'] && empty($cart->pricesUnformatted['billTotal'])) {
         $ph = array();
     } else {
         $ph = $bhelper->getPaymentArray();
     }
     $bhelper->createDefaultAddress($ref, $cart);
     $html = $bhelper->getPaymentArrayHtml($ref->cart, $ph, $sh);
     self::$totals_html = basketHelper::$totals_html;
     $bhelper->restoreDefaultAddress($ref, $cart);
     //$ret = implode('<br />', $sh);
     $ret = '';
     $ret .= $html;
     return $ret;
 }
Example #3
0
    function getShippingArrayHtml(&$ref, &$cart, $ajax = false)
    {
        if (!class_exists('OPCloader')) {
            require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'loader.php';
        }
        $op_disable_shipping = OPCloader::getShippingEnabled($cart);
        include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php';
        if (!$ajax && !empty($op_delay_ship)) {
            if (empty($op_disable_shipping)) {
                return array('<input type="hidden" name="invalid_country" id="invalid_country" value="invalid_country" /><input type="hidden" name="virtuemart_shipmentmethod_id" checked="checked" id="shipment_id_0" value="choose_shipping" />');
            } else {
                return array();
            }
        }
        basketHelper::createDefaultAddress($ref, $cart);
        $preselected2 = JRequest::getVar('shipping_rate_id', '');
        $preselected = JRequest::getVar('virtuemart_shipmentmethod_id', $preselected2);
        $found_shipment_method = false;
        $shipment_not_found_text = OPCLang::_('COM_VIRTUEMART_CART_NO_SHIPPING_METHOD_PUBLIC');
        $shipments_shipment_rates = array();
        if (!isset($ref->cart)) {
            $ref->cart = $cart;
        }
        if (!$this->checkShipmentMethodsConfigured() || !empty($op_disable_shipping)) {
            //define('NO_SHIPPING', '1');
            basketHelper::restoreDefaultAddress($ref, $cart);
            return array();
        }
        //
        $selectedShipment = empty($cart->virtuemart_shipmentmethod_id) ? 0 : $cart->virtuemart_shipmentmethod_id;
        if (empty($selectedShipment) && !empty($preselected)) {
            $selectedShipment = $preselected;
        }
        unset($_SESSION['load_fedex_prices_from_session']);
        $shipments_shipment_rates = array();
        if (!class_exists('vmPSPlugin')) {
            require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php';
        }
        JPluginHelper::importPlugin('vmshipment');
        $dispatcher = JDispatcher::getInstance();
        // never set any to be selected, we will select them later on:
        if (empty($selectedShipment)) {
            $selectedShipment = -1;
        }
        if (!empty($opc_calc_cache)) {
            $returnValues = $dispatcher->trigger('plgVmDisplayListFEShipmentOPC', array(&$cart, $selectedShipment, &$shipments_shipment_rates));
        } else {
            $returnValues = $dispatcher->trigger('plgVmDisplayListFEShipmentOPCNocache', array(&$cart, $selectedShipment, &$shipments_shipment_rates));
            if (empty($returnValues)) {
                $returnValues = $dispatcher->trigger('plgVmDisplayListFEShipment', array($cart, $selectedShipment, &$shipments_shipment_rates));
            }
        }
        // if no shipment rate defined
        $extraHtml = array();
        $found_shipment_method = false;
        foreach ($returnValues as $returnValue) {
            if ($returnValue) {
                $found_shipment_method = true;
                //$extraHtml[] = $returnValue;
                break;
            }
        }
        $shipment_not_found_text = OPCLang::_('COM_VIRTUEMART_CART_NO_SHIPPING_METHOD_PUBLIC');
        $ret = '';
        if ($found_shipment_method) {
            // if only one Shipment , should be checked by default
            $arr = array();
            $preselected = JRequest::getVar('selectedshipping');
            //if (empty($preselected) || ($preselected=='choose_shipping') || ($preselected=='shipment_id_0'))
            if (!empty($opc_default_shipping) && $opc_default_shipping == 3) {
                if (empty($shipping_inside) && !empty($shipping_inside_choose)) {
                    $choose = '
	<input type="radio" name="virtuemart_shipmentmethod_id" onclick="javascript:Onepage.changeTextOnePage3(op_textinclship, op_currency, op_ordertotal);" id="choose_shipping" value="choose_shipping">
	<label for="choose_shipping"><span class="vmshipment"><span class="vmshipment_name">- ' . OPClang::_('COM_VIRTUEMART_CART_EDIT_SHIPPING') . ' - </span></span></label>';
                    $arr[] = $choose;
                    $ret = $choose . $ret;
                }
            }
            foreach ($shipments_shipment_rates as $shipment_shipment_rate) {
                if (is_array($shipment_shipment_rate)) {
                    foreach ($shipment_shipment_rate as $shipment_shipment_rat) {
                        //if (!empty($shipping_template))
                        //OPCTransform::overrideShippingHtml($shipment_shipment_rat, $cart);
                        $arr[] = $shipment_shipment_rat;
                        $ret .= $shipment_shipment_rat . '<br />';
                    }
                }
            }
        } else {
            $shipment_not_found_text = $shipment_not_found_text . '<input type="hidden" name="invalid_country" id="invalid_country" value="invalid_country" /><input type="hidden" name="virtuemart_shipmentmethod_id" checked="checked" id="shipment_id_0" value="choose_shipping" />';
        }
        basketHelper::restoreDefaultAddress($ref, $cart);
        if (!empty($arr)) {
            return $arr;
        } else {
            return array($shipment_not_found_text);
        }
    }