コード例 #1
0
 function getConfig()
 {
     $cfg = new sc_configuration();
     $config['tsep'] = $cfg->get('thousand_sep');
     $config['dsep'] = $cfg->get('decimal_sep');
     $config['decs'] = $cfg->get('decimals');
     $config['currency'] = $cfg->get('currency');
     $config['showremove'] = $cfg->get('remove_button');
     $config['show_emptycart'] = $cfg->get('show_emptycart');
     $config['rightAlignCurency'] = $cfg->get('curralign');
     $config['stdprodcode'] = $cfg->get("cart_fee_product");
     return $config;
 }
コード例 #2
0
ファイル: simplecaddy.php プロジェクト: bizanto/Hooked
 function dis()
 {
     $cfg = new sc_configuration();
     $this->tsep = $cfg->get('thousand_sep');
     $this->dsep = $cfg->get('decimal_sep');
     $this->decs = $cfg->get('decimals');
     $this->currency = $cfg->get('currency');
     $this->curralign = $cfg->get('curralign');
 }
コード例 #3
0
ファイル: admin.caddy.html.php プロジェクト: bizanto/Hooked
    function view_prod($alist)
    {
        global $mainframe;
        $document = JFactory::getDocument();
        $stylesheet = JPATH_COMPONENT . DS . 'css' . DS . 'simplecaddy.css';
        $document->addStyleSheet($stylesheet);
        $e_name = JRequest::getVar('e_name');
        ?>
		<link rel="stylesheet" href="<?php 
        echo $stylesheet;
        ?>
" type="text/css" />
		<script type="text/javascript" language="javascript">
			function insertCode(plugincode) {
				var editor = '<?php 
        echo $e_name;
        ?>
';  
				var sccode = '{simplecaddy code='+plugincode;
                var compo=document.getElementById("component").value;
                if (compo=="com_phocagallery") {// special for PhocaGallery
                    var alias=window.parent.document.getElementById("alias").value;
                    sccode = sccode + " picname="+alias;    
                }
                var clssfx=document.getElementById("clssfx").value;
                if (clssfx!="") sccode = sccode + " classsfx="+clssfx;
                var defqty=document.getElementById("defqty").value;
                if (defqty!="") sccode = sccode + " defqty="+defqty;
                var minqty=document.getElementById("minqty").value;
                if (minqty!="") sccode = sccode + " minqty="+minqty;
                var qties=document.getElementById("qties").value;
                if (qties!="") sccode = sccode + " qties="+qties;
                var checkoos=document.getElementById("checkoos").value;
                if (checkoos!="") sccode = sccode + " checkoos=1";
                sccode = sccode + '}';
				window.parent.jInsertEditorText(sccode, editor);  
				window.parent.document.getElementById('sbox-window').close();
			}
			function insertCat(plugincode) {
				var editor = '<?php 
        echo $e_name;
        ?>
'; 
				var sccode = '{simplecaddy category='+plugincode+'}';
				window.parent.jInsertEditorText(sccode, editor); 
				window.parent.document.getElementById('sbox-window').close();
			}
		</script>
        <table class='codelist' width='100%'>
        <tr>
        <td>
            <?php 
        echo JText::_("SC_CLASS_SUFFIX");
        ?>
 
        </td>
        <td><input type="text" name="clssfx" id="clssfx" /></td>
        </tr>
        <tr>
        <td>
            <?php 
        echo JText::_("SC_DEF_QTY");
        ?>
 
        </td>
        <td><input type="text" name="defqty" id="defqty" /></td>
        </tr>
        <tr>
        <td>
            <?php 
        echo JText::_("SC_MIN_QTY");
        ?>
 
        </td>
        <td><input type="text" name="minqty" id="minqty" /></td>
        </tr>
        <tr>
        <td>
            <?php 
        echo JText::_("SC_QTIES");
        ?>
 
        </td>
        <td><input type="text" name="qties" id="qties" /></td>
        </tr>
        <tr>
        <td>
            <?php 
        $cfg = new sc_configuration();
        if ($cfg->get("checkminqty") == "1") {
            $disabled = "";
            echo JText::_("SC_CHECK_OOS");
        } else {
            $disabled = " disabled";
            echo JText::_("SC_NO_CHECK_OOS");
        }
        ?>
 
        </td>
        <td>
            
            <input type="checkbox" name="checkoos" id="checkoos" <?php 
        echo $disabled;
        ?>
 /></td>
        </tr>
        </table>
        <table class='codelist' width='100%'>
        <input type="hidden" name="component" id="component" value="<?php 
        echo JRequest::getVar("component");
        ?>
" />
		<?php 
        echo "<tr><th>" . JText::_('SC_CLICK_CODE') . "</th></tr>";
        $k = 0;
        foreach ($alist as $product) {
            echo "<tr class='row{$k}'><td>{$product->category}&nbsp;<a class='codelist' href='#' onclick=\"insertCode('{$product->prodcode}');\">{$product->shorttext} (code: {$product->prodcode})</a></td></tr>";
            $k = 1 - $k;
        }
        ?>
		</table>

        <?php 
        $cfg = new sc_configuration();
        $aclist = $cfg->get("prodcats");
        $clist = explode("\r\n", $aclist);
        echo "<table class='codelist' width='100%'>";
        echo "<tr><th>" . JText::_('SC_CLICK_CATEGORY') . "</th></tr>";
        $k = 0;
        foreach ($clist as $key => $cat) {
            echo "<tr class='row{$k}'><td><a class='codelist' href='#' onclick=\"insertCat('{$cat}');\">{$cat}</a></td></tr>";
            $k = 1 - $k;
        }
        echo "</table>";
    }
コード例 #4
0
 function displayValue($value)
 {
     $cfg = new sc_configuration();
     $tsep = $cfg->get('thousand_sep');
     $dsep = $cfg->get('decimal_sep');
     $decs = $cfg->get('decimals');
     $currency = $cfg->get('currency');
     $currleftalign = $cfg->get('curralign');
     $html = '';
     if ($currleftalign == 1) {
         $html .= "{$currency}&nbsp;" . number_format($value, $decs, $dsep, $tsep);
     } else {
         $html .= number_format($value, $decs, $dsep, $tsep) . "&nbsp;{$currency}";
     }
     return $html;
 }
コード例 #5
0
 function redeemvoucher($voucher)
 {
     global $mainframe;
     $cfg = new sc_configuration();
     $cfp = $cfg->get("taxrate");
     $cfp = str_replace("%", "", $cfp);
     if ($cfp > 1) {
         $cfp = $cfp / 100;
     }
     $taxrate = $cfp;
     $cartProd = new CartProduct();
     $cartProd->prodcode = "voucher";
     $cartProd->option = "";
     $cartProd->prodname = $voucher->name;
     $cartProd->unitprice = 0;
     $cartProd->quantity = 1;
     $cartProd->finalprice = 0;
     // matheval("$cartProd->unitprice $cartProd->formula");
     $cart = new cart2();
     $cart->removeCartProduct($cartProd);
     // remove any vouchers from the cart
     /**
     		$acart=$cart->readCart(); // returns array of cart products
     		$gtotal=0;
     		foreach ($acart as $key=>$cartproduct) {
     			$total=$cartproduct->quantity*$cartproduct->finalprice;
     			$gtotal= $gtotal + $total;
     		}
     */
     $gtotal = $cart->getCartTotal();
     $korting = $gtotal - matheval("{$gtotal} {$voucher->formula}");
     $cartProd->finalprice = $korting * -1;
     // just to get the amount back in the cart
     $cartProd->unitprice = $cartProd->finalprice;
     $cartProd->id = "voucher";
     $cart->addCartProduct($cartProd);
     // now return the values for immediate display
     $gtotal = $korting;
     $tax = $gtotal * $taxrate;
     $res['korting'] = $korting;
     $res['subtotal'] = $gtotal;
     $res['tax'] = $tax;
     $res['carttotal'] = $gtotal + $tax;
     return $res;
 }
コード例 #6
0
ファイル: caddy.class.php プロジェクト: bizanto/Hooked
 function getTax($shipZone = null)
 {
     $cfg = new sc_configuration();
     // calculate the standard tax rate
     $cfp = $cfg->get("taxrate");
     $cfp = str_replace("%", "", $cfp);
     if ($cfp > 1) {
         $cfp = $cfp / 100;
     }
     $taxrate = $cfp;
     if (!$shipZone) {
         // no shipping, show the standard tax rate
         return $taxrate;
     } else {
         $who = $cfg->get("whopaystax");
         if ($who == "all") {
             // get the standard tax rate for everyone, same as no shipping
             return $taxrate;
         }
         if ($who == "none") {
             // get the standard tax rate for everyone, same as no shipping
             return 0;
         }
         if ($who == "special") {
             // only some regions pay tax
             $stp = $cfg->get("taxpays");
             // get the regions
             $atp = explode("\r\n", $stp);
             foreach ($atp as $key => $value) {
                 // walk through regions for a match
                 if (strpos("{$value}", ":")) {
                     // if region contains a : then specific tax per regions are set
                     list($tzone, $cfp) = explode(":", $value);
                     // separate the region from taxrate
                     if ($tzone == $shipZone) {
                         // match for the region
                         // normalize the taxrate
                         $cfp = str_replace("%", "", $cfp);
                         if ($cfp > 1) {
                             $cfp = $cfp / 100;
                         }
                         $taxrate = $cfp;
                         return $taxrate;
                     }
                 } else {
                     // simple regions entered, just check for match and return standard rate
                     if ($shipZone == $value) {
                         return $taxrate;
                     }
                 }
             }
             return 0;
             // zone not found => no tax info return zero
         }
     }
 }
コード例 #7
0
ファイル: admin.caddy.php プロジェクト: bizanto/Hooked
     }
     break;
 case "configuration":
     switch ($task) {
         case "saveconfig":
             $cfgset = JRequest::getvar('cfgset');
             JRequest::setvar('task', "configuration");
             $cfg = new sc_configuration($cfgset);
             $cfg->setAll();
             $mainframe->redirect("index.php?option=com_caddy&action=configuration&task=show", JText::_("Configuration saved"));
         case "cancel":
             $mainframe->redirect("index.php?option=com_caddy&action=configuration&task=show", JText::_("Reverting to previous Configuration"));
         default:
             $cfgset = JRequest::getvar('cfgset');
             JRequest::setvar('task', "configuration");
             $cfg = new sc_configuration($cfgset);
             display::header();
             $cfg->show();
             break;
     }
     break;
 case "view_prod":
     $a = new products();
     $alist = $a->getPublishedProducts();
     display::view_prod($alist);
     break;
 case "about":
     switch ($task) {
         default:
             JRequest::setvar('task', "about");
             display::ShowAbout();
コード例 #8
0
ファイル: scpaypal.class.php プロジェクト: bizanto/Hooked
 function checkout($orderid, $ship = null)
 {
     // it uses the simple way to upload a cart with contents to paypal as explained here:
     // https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_cart_upload#id08A3F700OYK
     // data available December 28, 2009.
     //get PayPal configuration
     $cfg = new sc_configuration();
     $reselleremail = $cfg->get("reselleremail");
     $ppcurrency = $cfg->get("paypalcurrency");
     $environment = $cfg->get("ppenvironment");
     // live or sandbox
     $ctax = new taxes();
     $taxrate = $ctax->getTax(@$ship['region']);
     if (!$reselleremail) {
         echo "Reseller email is not entered, please add this to the configuration first. PayPal cannot be used!";
         return;
     }
     // add the details to the order
     $gtotal = 0;
     //define the grand total
     $pptax = 0;
     // define the tax for paypal
     if ($environment == 0) {
         // live
         $html = "<form action='https://www.paypal.com/cgi-bin/webscr' method='post' name ='ppform' target='paypal'>";
     } else {
         // sandbox
         $html = "<form action='https://www.sandbox.paypal.com/cgi-bin/webscr' method='post' name ='ppform' target='paypal'>";
     }
     $html .= "<input type=\"{$this->debugshow}\" name=\"cmd\" value=\"_cart\">";
     $html .= "<input type=\"{$this->debugshow}\" name=\"upload\" value=\"1\">";
     $html .= "<input type=\"{$this->debugshow}\" name=\"business\" value=\"{$reselleremail}\">";
     $html .= "<input type=\"{$this->debugshow}\" name=\"currency_code\" value=\"{$ppcurrency}\">";
     $html .= "<input type=\"{$this->debugshow}\" name=\"rm\" value=\"2\">";
     $fieldnumber = 0;
     // PayPal field numbering variable
     $odetails = new orderdetail();
     $lst = $odetails->getDetailsByOrderId($orderid);
     foreach ($lst as $product) {
         // create a post field and field value for PayPal
         if ($product->total > 0) {
             // price positive, so standard product to be paid for
             $fieldnumber = $fieldnumber + 1;
             //increment the field number (could also be done with $fieldnumber++)
             $html .= "<input type='{$this->debugshow}' name='item_name_" . $fieldnumber . "' value='" . $product->shorttext . " (" . $product->prodcode . ") " . $product->option . "'>";
             $html .= "<input type='{$this->debugshow}' name='amount_" . $fieldnumber . "' value='" . $product->unitprice . "'>";
             $html .= "<input type='{$this->debugshow}' name='quantity_" . $fieldnumber . "' value='" . $product->qty . "'>";
         } else {
             $html .= "<input type='{$this->debugshow}' name='discount_amount_cart' value='" . abs($product->total) . "'>";
         }
         $gtotal += $product->total;
     }
     if ($taxrate > 0) {
         // taxes to be applied!
         // check if taxes should be paid on shipping
         $taxonshipping = $cfg->get("taxonshipping");
         if ($taxonshipping == 1) {
             // tax is calculated on shipping cost
             $pptax = $gtotal * $taxrate + $ship['cost'] * $taxrate;
         } else {
             $pptax = $gtotal * $taxrate;
         }
     }
     if ($pptax > 0) {
         //either one or both of the taxes have to be applied, so we add the tax field for PP
         $html .= "<input type=\"{$this->debugshow}\" name=\"tax_cart\" value=\"" . number_format($pptax, 2, ".", "") . '">';
         //
     }
     if ($ship['enabled']) {
         $html .= "<input type=\"{$this->debugshow}\" name=\"shipping_1\" value=\"" . $ship['cost'] . "\">";
     }
     $html .= "<input type=\"{$this->debugshow}\" name=\"custom\" value=\"{$orderid}\">";
     // these are the return urls to go to when coming back from paypal
     $successurl = JURI::base(false) . "index.php?option=com_caddy&action=paysuccess";
     $failurl = JURI::base(false) . "index.php?option=com_caddy&action=payfail";
     $html .= "<input type=\"{$this->debugshow}\" name=\"cancel_return\" value=\"{$failurl}\">";
     $html .= "<input type=\"{$this->debugshow}\" name=\"return\" value=\"{$successurl}\">";
     $html .= JText::_('SC_WE_USE_PAYPAL');
     // PayPal requires you use their logo to check out. Check the PayPal site for other button types
     // look here for more buttons from PayPal https://www.paypal.com/newlogobuttons
     // look here for the rules of usage of the paypal logos and pay buttons:
     //https://www.paypalobjects.com/WEBSCR-640-20110401-1/en_US/pdf/merchant_graphic_guidelines.pdf
     /** customizers, do your stuff here!
     You may add all kinds of fields now to the paypal "cart" to customize your heading in PayPal and so on.
     None of these novelties have been added here, but if you want to customize the appearance of your presence in Paypal,
     Here is the place.
     
     */
     $html .= '<p>
     <input type="image" name="submit" src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" align="left" style="margin-right:7px;"> <span style="font-size:11px; font-family: Arial, Verdana;">The safer, easier way to pay.</span>
     <p>';
     // additional PayPal info
     // be careful to 'escape' any " with \ !
     /**
             $html .="<p>
     <!-- PayPal Logo --><table border=\"0\" cellpadding=\"10\" cellspacing=\"0\" align=\"center\"><tr><td align=\"center\"></td></tr>
     <tr><td align=\"center\"><a href=\"#\" onclick=\"javascript:window.open('https://www.paypal.com/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside','olcwhatispaypal','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=400, height=350');\">
     <img  src=\"https://www.paypal.com/en_US/i/bnr/vertical_solution_PPeCheck.gif\" border=\"0\" alt=\"Solution Graphics\"></a></td></tr></table><!-- PayPal Logo -->        
             </p>";
     */
     // otherwise we could use a simple submit button:
     //$html .='<input type="submit" value="PayPal">  ';
     $html .= "</form>";
     // if you want to add more text here
     // add it here like this:
     // $html .= "Your text here";
     // *before* the line below
     echo $html;
     // display the html.
 }
コード例 #9
0
ファイル: caddy.html.php プロジェクト: bizanto/Hooked
    function view_prod($alist)
    {
        global $mainframe;
        $stylesheet = JPATH_COMPONENT . DS . 'css' . DS . 'simplecaddy.css';
        ?>
		<link rel="stylesheet" href="<?php 
        echo $stylesheet;
        ?>
" type="text/css" />
		<script type="text/javascript" language="javascript">
			function insertCode(plugincode) {
				var sccode = '{simplecaddy code='+plugincode+'}';
				window.parent.jInsertEditorText(sccode, 'text');
				window.parent.document.getElementById('sbox-window').close();
			}
			function insertCat(plugincode) {
				var sccode = '{simplecaddy category='+plugincode+'}';
				window.parent.jInsertEditorText(sccode, 'text');
				window.parent.document.getElementById('sbox-window').close();
			}
		</script>
		<?php 
        echo "<table class='codelist' width='100%'>";
        echo "<tr><th>" . JText::_('SC_CLICK_CODE') . "</th></tr>";
        $k = 0;
        foreach ($alist as $product) {
            echo "<tr class='row{$k}'><td>{$product->category}&nbsp;<a class='codelist' href='#' onclick=\"insertCode('{$product->prodcode}');\">{$product->shorttext} (code: {$product->prodcode})</a></td></tr>";
            $k = 1 - $k;
        }
        echo "</table>";
        $cfg = new sc_configuration();
        $aclist = $cfg->get("prodcats");
        $clist = explode("\r\n", $aclist);
        echo "<table class='codelist' width='100%'>";
        echo "<tr><th>" . JText::_('SC_CLICK_CATEGORY') . "</th></tr>";
        $k = 0;
        foreach ($clist as $key => $cat) {
            echo "<tr class='row{$k}'><td><a class='codelist' href='#' onclick=\"insertCat('{$cat}');\">{$cat}</a></td></tr>";
            $k = 1 - $k;
        }
        echo "</table>";
    }
コード例 #10
0
ファイル: caddy.php プロジェクト: bizanto/Hooked
function AddStandard()
{
    $cfg = new sc_configuration();
    $stdprod = $cfg->get("cart_fee_product");
    if ($stdprod != "") {
        $tmp = new products();
        $sp = $tmp->getproductByProdCode($stdprod);
        $cartProd = new CartProduct();
        $cartProd->option = "";
        $cartProd->prodcode = $stdprod;
        $cartProd->prodname = $sp->shorttext;
        $cartProd->unitprice = $sp->unitprice;
        $cartProd->quantity = 1;
        $cartProd->finalprice = $sp->unitprice;
        $cartProd->id = uniqid("S");
        $cart2 = new cart2();
        $cart2->removecartProduct($cartProd);
        $c = $cart2->readcart();
        if (count($c) > 0) {
            $cart2->addCartProduct($cartProd);
        }
    }
}