當前位置: 首頁>>代碼示例>>PHP>>正文


PHP J2Store::plugin方法代碼示例

本文整理匯總了PHP中J2Store::plugin方法的典型用法代碼示例。如果您正苦於以下問題:PHP J2Store::plugin方法的具體用法?PHP J2Store::plugin怎麽用?PHP J2Store::plugin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在J2Store的用法示例。


在下文中一共展示了J2Store::plugin方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getRelatedProducts

 /**
  * Method to get Related products
  *
  */
 public function getRelatedProducts()
 {
     $app = JFactory::getApplication();
     $db = JFactory::getDbo();
     $q = $app->input->post->getString('q');
     $ignore_product_id = $app->input->getInt('product_id');
     $json = array();
     $model = $this->getModel('Products');
     $model->setState('search', $q);
     $query = $db->getQuery(true);
     $query->select('#__j2store_products.j2store_product_id')->from("#__j2store_products as #__j2store_products");
     $query->where('#__j2store_products.enabled=1');
     $query->where('#__j2store_products.j2store_product_id !=' . $db->q($ignore_product_id));
     J2Store::plugin()->importCatalogPlugins();
     JFactory::getApplication()->triggerEvent('onJ2StoreAfterProductListQuery', array(&$query, &$model));
     $db->setQuery($query);
     $items = $db->loadObjectList();
     $result = array();
     if (isset($items) && !empty($items)) {
         foreach ($items as $key => $item) {
             if ($item->product_name) {
                 $result[$key]['j2store_product_id'] = $item->j2store_product_id;
                 $result[$key]['product_name'] = $item->product_name;
             }
         }
     }
     $json['products'] = $result;
     echo json_encode($json);
     $app->close();
 }
開發者ID:davetheapple,項目名稱:oakencraft,代碼行數:34,代碼來源:productbase.php

示例2: sendVouchers

 public function sendVouchers($cids)
 {
     $app = JFactory::getApplication();
     $config = JFactory::getConfig();
     $params = J2Store::config();
     $sitename = $config->get('sitename');
     $emailHelper = J2Store::email();
     $mailfrom = $config->get('mailfrom');
     $fromname = $config->get('fromname');
     $failed = 0;
     foreach ($cids as $cid) {
         $voucherTable = F0FTable::getAnInstance('Voucher', 'J2StoreTable')->getClone();
         $voucherTable->load($cid);
         $mailer = JFactory::getMailer();
         $mailer->setSender(array($mailfrom, $fromname));
         $mailer->isHtml(true);
         $mailer->addRecipient($voucherTable->email_to);
         $mailer->setSubject($voucherTable->subject);
         // parse inline images before setting the body
         $emailHelper->processInlineImages($voucherTable->email_body, $mailer);
         $mailer->setBody($voucherTable->email_body);
         //Allow plugins to modify
         J2Store::plugin()->event('BeforeSendVoucher', array($voucherTable, &$mailer));
         if ($mailer->Send() !== true) {
             $this->setError(JText::sprintf('J2STORE_VOUCHERS_SENDING_FAILED_TO_RECEIPIENT', $voucherTable->email_to));
             $failed++;
         }
         J2Store::plugin()->event('AfterSendVoucher', array($voucherTable, &$mailer));
         $mailer = null;
     }
     if ($failed > 0) {
         return false;
     }
     return true;
 }
開發者ID:jputz12,項目名稱:OneNow-Vshop,代碼行數:35,代碼來源:vouchers.php

示例3: onBeforeDelete

 protected function onBeforeDelete($oid)
 {
     $status = true;
     // load cart items
     $query = $this->_db->getQuery(true);
     $query->select('*')->from('#__j2store_cartitems')->where('cart_id = ' . (int) $oid);
     $this->_db->setQuery($query);
     try {
         $items = $this->_db->loadObjectList();
         // foreach orderitem
         foreach ($items as $item) {
             // remove from user's cart
             if (!F0FTable::getAnInstance('Cartitem', 'J2StoreTable')->delete($item->j2store_cartitem_id)) {
                 //F0FTable::getAnInstance ( 'Cartitem', 'J2StoreTable' )->getError();
                 break;
                 return false;
             } else {
                 J2Store::plugin()->event('RemoveCartItem', array($item));
                 $status = true;
             }
         }
     } catch (Exception $e) {
         // do nothing
     }
     return $status;
 }
開發者ID:jputz12,項目名稱:OneNow-Vshop,代碼行數:26,代碼來源:cart.php

示例4: buildQuery

 public function buildQuery($overrideLimits = false)
 {
     $db = JFactory::getDbo();
     $query = $db->getQuery(true)->select('#__j2store_product_prices.*')->from('#__j2store_product_prices');
     $this->_buildQueryWhere($query);
     $this->_buildQueryOrder($query);
     J2Store::plugin()->event('ProductPricesAfterBuildQuery', array(&$query, &$this));
     return $query;
 }
開發者ID:davetheapple,項目名稱:oakencraft,代碼行數:9,代碼來源:productprices.php

示例5: onBrowse

 public function onBrowse($tpl = null)
 {
     $systemPlugin = JPluginHelper::isEnabled('system', 'j2store');
     if (!$systemPlugin) {
         //System plugin disabled. Manually enable it
         J2Store::plugin()->enableJ2StorePlugin();
     }
     $this->assign('systemPlugin', $systemPlugin);
     $this->assign('cachePlugin', JPluginHelper::isEnabled('system', 'cache'));
     $this->assign('params', J2Store::config());
     return true;
 }
開發者ID:davetheapple,項目名稱:oakencraft,代碼行數:12,代碼來源:view.html.php

示例6: getStockProductListQuery

 public function getStockProductListQuery($overrideLimits = false)
 {
     $db = JFactory::getDbo();
     $query = $db->getQuery(true)->select('#__j2store_productquantities.*')->from('#__j2store_productquantities');
     $this->_buildQueryJoins($query);
     $this->_buildWhereQuery($query);
     $this->_buildQueryOrderBy($query);
     $query->group('#__j2store_products.j2store_product_id');
     //$query->group('#__j2store_productquantities.variant_id');
     J2Store::plugin()->event('AfterStockProductListQuery', array(&$query, &$this));
     return $query;
 }
開發者ID:davetheapple,項目名稱:oakencraft,代碼行數:12,代碼來源:inventories.php

示例7: calculate

 public function calculate()
 {
     $variant = $this->get('variant');
     $quantity = $this->get('quantity');
     $date = $this->get('date');
     $group_id = $this->get('group_id');
     $pricing = new JObject();
     //set the base price
     $pricing->base_price = $variant->price;
     $pricing->price = $variant->price;
     $pricing->calculator = 'standard';
     //see if we have advanced pricing for this product / variant
     $model = F0FModel::getTmpInstance('ProductPrices', 'J2StoreModel');
     J2Store::plugin()->event('BeforeGetPrice', array(&$pricing, &$model));
     $model->setState('variant_id', $variant->j2store_variant_id);
     //where quantity_from < $quantity
     $model->setState('filter_quantity', $quantity);
     $tz = JFactory::getConfig()->get('offset');
     // does date even matter?
     $nullDate = JFactory::getDBO()->getNullDate();
     if (empty($date) || $date == $nullDate) {
         $date = JFactory::getDate('now', $tz)->toSql(true);
     }
     //where date_from <= $date
     //where date_to >= $date OR date_to == nullDate
     $model->setState('filter_date', $date);
     // does group_id?
     $user = JFactory::getUser();
     if (empty($group_id)) {
         $group_id = implode(',', JAccess::getGroupsByUser($user->id));
     }
     //if(empty($group_id)) $group_id = implode(',', JAccess::getAuthorisedViewLevels($user->id));
     $model->setState('group_id', $group_id);
     // set the ordering so the most discounted item is at the top of the list
     $model->setState('orderby', 'quantity_from');
     $model->setState('direction', 'DESC');
     try {
         $price = $model->getItem();
         //var_dump($price);
     } catch (Exception $e) {
         $price = new stdClass();
     }
     if (isset($price->price)) {
         $pricing->special_price = $price->price;
         //this is going to be the sale price
         $pricing->price = $price->price;
         $pricing->is_discount_pricing_available = $pricing->base_price > $pricing->price ? true : false;
     }
     return $pricing;
 }
開發者ID:davetheapple,項目名稱:oakencraft,代碼行數:50,代碼來源:standardcalculator.php

示例8: getShippingRates

 public function getShippingRates(&$order)
 {
     static $rates;
     if (empty($rates) || !is_array($rates)) {
         $rates = array();
     }
     if (!empty($rates)) {
         return $rates;
     }
     $app = JFactory::getApplication();
     JPluginHelper::importPlugin('j2store');
     $plugins = $this->enabled(1)->getList();
     $rates = array();
     if ($plugins) {
         foreach ($plugins as $plugin) {
             $shippingOptions = $app->triggerEvent("onJ2StoreGetShippingOptions", array($plugin->element, $order));
             if (in_array(true, $shippingOptions, true)) {
                 $results = $app->triggerEvent("onJ2StoreGetShippingRates", array($plugin->element, $order));
                 foreach ($results as $result) {
                     if (is_array($result)) {
                         foreach ($result as $r) {
                             $extra = 0;
                             // here is where a global handling rate would be added
                             //	if ($global_handling = $this->defines->get( 'global_handling' ))
                             //	{
                             //		$extra = $global_handling;
                             //	}
                             J2Store::plugin()->event('GetGlobalHandling', array($order, &$r, &$extra));
                             $r['extra'] += $extra;
                             $r['total'] += $extra;
                             $rates[] = $r;
                         }
                     }
                 }
             }
         }
     }
     //order by the cheapest method
     if (function_exists('usort') && count($rates)) {
         usort($rates, function ($a, $b) {
             return $a['total'] - $b['total'];
         });
     }
     return $rates;
 }
開發者ID:davetheapple,項目名稱:oakencraft,代碼行數:45,代碼來源:shippings.php

示例9: addAddress

 function addAddress($type = 'billing', $data = array())
 {
     $app = JFactory::getApplication();
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     if (isset($data) && count($data)) {
         $post = $data;
     } else {
         $post = $app->input->getArray($_POST);
     }
     foreach ($post as $key => $value) {
         // in case the value is an array, store as a json encoded message
         if (is_array($value)) {
             $post[$key] = $db->escape(json_encode($value));
         }
     }
     // first save data to the address table
     $row = F0FTable::getInstance('Address', 'J2StoreTable');
     // set the id so that it updates the record rather than changing
     if (!$row->bind($post)) {
         $this->setError($row->getError());
         return false;
     }
     J2Store::plugin()->event('BeforeSaveAddress', array(&$row, $post));
     if ($user->id) {
         $row->user_id = $user->id;
         $row->email = $user->email;
     }
     $row->type = $type;
     if (!$row->store()) {
         $this->setError($row->getError());
         return false;
     }
     J2Store::plugin()->event('AfterSaveAddress', array(&$row, $post));
     return $row->j2store_address_id;
 }
開發者ID:davetheapple,項目名稱:oakencraft,代碼行數:36,代碼來源:addresses.php

示例10: array

  <div class="row">
  <div class="col-xs-11 shipping-make-same" style="clear: both; padding-top: 15px;">
	  <input type="checkbox" name="shipping_address" value="1" id="shipping" checked="checked" />
	  <label for="shipping"><?php 
    echo JText::_('J2STORE_MAKE_SHIPPING_SAME');
    ?>
</label>
  </div>
  </div> <!-- end of row -->
  <br />
  <?php 
}
?>

<?php 
echo J2Store::plugin()->eventWithHtml('CheckoutRegister', array($this));
?>
<div class="buttons">
  <div class="left">
    <input type="button" value="<?php 
echo JText::_('J2STORE_CHECKOUT_CONTINUE');
?>
" id="button-register" class="button btn btn-primary" />
  </div>
</div>
<input type="hidden" name="option" value="com_j2store" />
<input type="hidden" name="view" value="checkout" />
<input type="hidden" name="task" value="register_validate" />

</div> <!-- end of j2store -->
開發者ID:Fabrik,項目名稱:website,代碼行數:30,代碼來源:default_register.php

示例11: array

    echo JText::_('J2STORE_CHECKOUT_PASSWORD');
    ?>
</b><br />
		<input type="password" name="password" value="" />
		<br />
		<input type="button" value="<?php 
    echo JText::_('J2STORE_CHECKOUT_LOGIN');
    ?>
" id="button-login" class="button btn btn-primary" /><br />
		<input type="hidden" name="task" value="login_validate" />
		<input type="hidden" name="option" value="com_j2store" />
		<input type="hidden" name="view" value="checkout" />
		<br />
		<?php 
    $forgot_pass_link = JRoute::_('index.php?option=com_users&view=reset');
    ?>
		<a href="<?php 
    echo $forgot_pass_link;
    ?>
" target="_blank"><?php 
    echo JText::_('J2STORE_FORGOT_YOUR_PASSWORD');
    ?>
</a>
	</div>
</div>
<?php 
}
echo J2Store::plugin()->eventWithHtml('CheckoutLogin', array($this));
?>
<input type="hidden" name="option" value="com_j2store" />
<input type="hidden" name="view" value="checkout" />
開發者ID:Fabrik,項目名稱:website,代碼行數:31,代碼來源:default_login.php

示例12: array

"
				   />

	   </div>
	<?php 
} else {
    ?>
			<input value="<?php 
    echo JText::_('J2STORE_OUT_OF_STOCK');
    ?>
" type="button" class="j2store_button_no_stock btn btn-warning" />
	<?php 
}
?>

	<?php 
echo J2Store::plugin()->eventWithHtml('AfterAddToCartButton', array($this->product, J2Store::utilities()->getContext('view_cart')));
?>

	<input type="hidden" name="option" value="com_j2store" />
	<input type="hidden" name="view" value="carts" />
	<input type="hidden" name="task" value="addItem" />
	<input type="hidden" name="ajax" value="0" />
	<?php 
echo JHTML::_('form.token');
?>
	<input type="hidden" name="return" value="<?php 
echo base64_encode(JUri::getInstance()->toString());
?>
" />
	<div class="j2store-notifications"></div>
開發者ID:davetheapple,項目名稱:oakencraft,代碼行數:31,代碼來源:view_cart.php

示例13: validateOptionRules

 public function validateOptionRules($value, $option, &$errors)
 {
     if ($option->type == 'date' || $option->type == 'datetime') {
         $tz = JFactory::getConfig()->get('offset');
         if (!empty($option->option_params)) {
             $params = new JRegistry($option->option_params);
         } else {
             $params = new JRegistry('{}');
         }
         if ($params->get('hide_pastdates', 0)) {
             $now = JFactory::getDate('now', $tz);
             $date = JFactory::getDate($value, $tz);
             $interval = $now->diff($date);
             //	print_r($interval);
             $val = (int) $interval->format('%R%a');
             //echo $interval->format('%R%a');
             if ($val < 0) {
                 $errors['error']['option'][$option->j2store_productoption_id] = JText::_('J2STORE_DATE_VALIDATION_ERROR_PAST_DATE');
             }
         }
     }
     J2Store::plugin()->event('ValidateOptionRules', array($value, $option, $errors));
 }
開發者ID:davetheapple,項目名稱:oakencraft,代碼行數:23,代碼來源:options.php

示例14: onBeforeAddCartItem

 public function onBeforeAddCartItem(&$model, $product, &$json)
 {
     $app = JFactory::getApplication();
     $product_helper = J2Store::product();
     $values = $app->input->getArray($_REQUEST);
     $errors = array();
     //run quantity check
     $quantity = $app->input->get('product_qty');
     if (isset($quantity)) {
         $quantity = $quantity;
     } else {
         $quantity = 1;
     }
     //get options
     //get the product options
     $options = $app->input->get('product_option', array(0), 'ARRAY');
     if (isset($options)) {
         $options = array_filter($options);
     } else {
         $options = array();
     }
     //iterate through stored options for this product and validate
     foreach ($product->product_options as $product_option) {
         //check option type should not be file
         if ($product_option->required && empty($options[$product_option->j2store_productoption_id])) {
             $errors['error']['option'][$product_option->j2store_productoption_id] = JText::sprintf('J2STORE_ADDTOCART_PRODUCT_OPTION_REQUIRED', $product_option->option_name);
         }
         if (!empty($options[$product_option->j2store_productoption_id])) {
             F0FModel::getTmpInstance('Options', 'J2StoreModel')->validateOptionRules($options[$product_option->j2store_productoption_id], $product_option, $errors);
         }
     }
     $cart = $model->getCart();
     if (!$errors && $cart->cart_type != 'wishlist') {
         //before validating, get the total quantity of this variant in the cart
         $cart_total_qty = $product_helper->getTotalCartQuantity($product->variants->j2store_variant_id);
         //validate minimum / maximum quantity
         $error = $product_helper->validateQuantityRestriction($product->variants, $cart_total_qty, $quantity);
         if (!empty($error)) {
             $errors['error']['stock'] = $error;
         }
         //validate inventory
         if ($product_helper->check_stock_status($product->variants, $cart_total_qty + $quantity) === false) {
             $errors['error']['stock'] = JText::_('J2STORE_OUT_OF_STOCK');
         }
     }
     if (!$errors) {
         //all good. Add the product to cart
         // create cart object out of item properties
         $item = new JObject();
         $item->user_id = JFactory::getUser()->id;
         $item->product_id = (int) $product->j2store_product_id;
         $item->variant_id = (int) $product->variants->j2store_variant_id;
         $item->product_qty = J2Store::utilities()->stock_qty($quantity);
         $item->product_options = base64_encode(serialize($options));
         $item->product_type = $product->product_type;
         $item->vendor_id = isset($product->vendor_id) ? $product->vendor_id : '0';
         // onAfterCreateItemForAddToCart: plugin can add values to the item before it is being validated /added
         // once the extra field(s) have been set, they will get automatically saved
         $results = J2Store::plugin()->event("AfterCreateItemForAddToCart", array($item, $values));
         foreach ($results as $result) {
             foreach ($result as $key => $value) {
                 $item->set($key, $value);
             }
         }
         // no matter what, fire this validation plugin event for plugins that extend the checkout workflow
         $results = array();
         $results = J2Store::plugin()->event("BeforeAddToCart", array($item, $values, $product, $product->product_options));
         foreach ($results as $result) {
             if (!empty($result['error'])) {
                 $errors['error']['general'] = $result['error'];
             }
         }
         // when there is some error from the plugin then the cart item should not be added
         if (!$errors) {
             //add item to cart
             $cartTable = $model->addItem($item);
             if ($cartTable === false) {
                 //adding to cart is failed
                 $errors['success'] = 0;
             } else {
                 //adding cart is successful
                 $errors['success'] = 1;
                 $errors['cart_id'] = $cartTable->j2store_cart_id;
             }
         }
     }
     $json->result = $errors;
 }
開發者ID:davetheapple,項目名稱:oakencraft,代碼行數:88,代碼來源:cartsimple.php

示例15: defined

<?php

/**
 * @package J2Store
 * @copyright Copyright (c)2014-17 Ramesh Elamathi / J2Store.org
 * @license GNU GPL v3 or later
 */
// No direct access to this file
defined('_JEXEC') or die;
JHtml::_('behavior.modal');
$row = $this->item;
?>
	<?php 
$results = J2Store::plugin()->eventWithHtml('GetAppView', array($row));
?>
	<h3><?php 
echo JText::_($row->name);
?>
</h3>
	<?php 
echo $results;
開發者ID:davetheapple,項目名稱:oakencraft,代碼行數:21,代碼來源:view.php


注:本文中的J2Store::plugin方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。