Joomla Fabrik email plugin: email to (eval) - joomla

I have a Fabrik form that should be selecting an email address to mail to based off the selection the user makes on the frontend select box. The code I am using came directly from the Fabrik docs but does not seem to be working:
My form value and labels are as such:
general => General
booking => Booking
entertainment => Entertainment
<?php
$contact = $this->data['contact___reason_for_contact'];
switch ($contact) {
case 'general':
$email = 'email1#mail.com, emailw#mail.com';
break;
case 'booking':
$email = 'email3#mail.com, email4#mail.com';
break;
case 'catering':
$email = 'email5#mail.com, email6#mail.com';
break;
}
return $email;
?>
edit: link to fabrik docs

Related

Allow only one product in cart

Running joomla 3.4.8 and VM 3.0.12
I need to allow only one product in cart. I mean, if the client add a product to the cart and then if he/she wants to add another product don't allow it showing error message like " you can't have more than one product in cart"
You can alter the add() function in the cart controller page to achieve it. You can write code something like this
$cart = VirtueMartCart::getCart();
$prdata = $cart->cartProductsData;
$qty = 0;
foreach($prdata as $pdata)
{
$qty = $qty + $pdata['quantity'];
}
if ($cart) {
$virtuemart_product_ids = vRequest::getInt('virtuemart_product_id');
$error = false;
if($qty>=1)
{
$msg = vmText::_('you can't have more than one product in cart');
$type = 'warning';
}
else
{
$cart->add($virtuemart_product_ids,$error);
Use the same logic in updatecart() function in the same page.
If you using Fancypopup addtocart, then use the code in addJS function instead of add() function.

Programatically duplicated product not displayed on frontend in magento (ver 1.9.0.1)

I use the following script (inside a controller - action for now) for duplicating a product programatically.
public function indexAction()
{
$data = $this->getRequest()->getParams();
$product = Mage::getModel('catalog/product');
$_product = $product->loadByAttribute('sku',$data['prod_sku']);
$clone = $_product->duplicate();
$clone->setSku($data['new_sku']);
$clone->setUrlKey('foo-bar-1');
$qty = 99;
$is_in_stock = 1;
$stockArray = array(
'use_config_manage_stock' => 0,
'manage_stock' => 1,
'qty' => $qty,
'is_in_stock' => $is_in_stock,
);
$storeid=0; // your store id 0 is for default store id
Mage::getModel('catalog/product_status')->updateProductStatus($clone->getId(), $storeid, Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
$clone->setWebsiteIds(array(Mage::app()->getStore(true)->getWebsite()->getId()));
try{
$clone->getResource()->save($clone);
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($clone->getId());
foreach($stockArray as $key => $val){
$stockItem->setData($key, $val);
}
$stockItem->save();
} catch(Exception $e){
Mage::log($e->getMessage());
}
echo "new product ID is ".$clone->getId();
}
This works well and the product gets duplicated with supplied SKU and overwritten prices from a form.
I can see the product in product grid in admin panel.
Visibility is set to Catalog, Search
Product is in stock
Enabled and tagged to correct category and website.
Most probably, you can not see product on frontend, because it is not available in needed website. Provided code can be executed correctly only in admin area (in frontend controller "Warning: Invalid argument supplied for foreach() in app/code/core/Mage/Eav/Model/Entity/Abstract.php on line 1180" will be generated), so code: Mage::app()->getStore(true)->getWebsite()->getId() returned 0, that can not be correct website for frontend.
You should replace line:
$clone->setWebsiteIds(array(Mage::app()->getStore(true)->getWebsite()->getId()));
with
$clone->setWebsiteIds($_product->getWebsiteIds());

Displaying list of logged in users in Front side using Joomla 2.5 component

I would like to display all login user list in Front side using Joomla 2.5 component.
Can any body tell me how do do this?
I would also want to develop change password and news subscription module.
Try this,
$db =JFactory::getDBO();
$query = $db->getQuery(true);
$query->select('*')
->from('#__users');
$db->setQuery($query);
$rows = $db->loadObjectList();
foreach ($rows as $row) {
$user = JFactory::getUser($row->id);
$status = $user->guest;
if(!$status){
echo $row->name.'---Email'.$row->email;
}
}
Use this extension to implement its in your site if you need quick solution.
Hope it helps..

How can I retrieve shopping cart contents, shipping details and ancillary fees (tax, discounts, etc) for my custom payment method?

I'm tasked to write a custom payment method for Magento CE, and tinkered with it for the last couple of weeks. Although I'm an experienced developer, this was my first serious brush with php and Magento itself.
Please note this a web payment gateway, so I'm using
public function getOrderPlaceRedirectUrl() { ... }
In my Payment Method Model to redirect the customer to the external url successfully.
The issue that kept me stuck for a full day is how to retrieve checkout shopping cart contents, shipping details and ancillary fees (tax, discounts, etc). This info needs to be sent to the payment method API.
The code I've been using in my Payment Method Model is something like this:
$order_id = Mage::getSingleton("checkout/session")->getLastRealOrderId();
$order = Mage::getModel('sales/order')->loadByIncrementId($order_id);
$oBillingAddress = $order->getBillingAddress(); //this works ok
$total = number_format($order->getBaseGrandTotal(), 2, '', ''); //this too
/* The following code won't work */
$oShippingAddress = $order->getShippingAddress(); // is unset!?
$oShippingAddress->getSameAsBilling(); //HOW can I check this?
$amount = array();
$quantity = array();
$sku = array();
$description = array();
$cart_items = $order()->getAllVisibleItems();
foreach ($cart_items as $item) {
$amount[] = number_format($item->getPrice(), 2, '', ''); //ok
$quantity[] = $item->getQtyToInvoice(); // is empty...
$sku[] = $item->getSku(); // nothing either??
$description[] = $item->getName(); //this is working
}
Please, wizards of Magento, tell what am I doing wrong here?
Magento dev has been very frustrating, mainly for its lack of straightforward documentation. I'm sure it's very customizable and what not, but the abuse of php's magic functions and it's cumbersome structure has been challenging - at the least.
I think you need to get the quote. Something like this should work:
$quote = Mage::getSingleton('checkout/session')->getQuote();
$items = $quote->getAllVisibleItems();
foreach ($items as $item) {
$amount[] = number_format($item->getPrice(), 2, '', ''); //ok
$quantity[] = $item->getQtyToInvoice(); // is empty...
$sku[] = $item->getSku(); // nothing either??
$description[] = $item->getName(); //this is working
}
If you still need the order, let me know..

How to use the Email template in Magento

I develop my store in magento community edition 1.5.0.1. I need a Email template that content will be editable by admin. I create a email template through admin "Transactional Emails". Now I need to access and use that email from my custom module. How do I get it?, you have any idea let me know.
This should do it.
public function sendTransactionalEmail() {
// Transactional Email Template's ID
$templateId = 1;
// Set sender information
$senderName = Mage::getStoreConfig('trans_email/ident_support/name');
$senderEmail = Mage::getStoreConfig('trans_email/ident_support/email');
$sender = array('name' => $senderName,
'email' => $senderEmail);
// Set recepient information
$recepientEmail = 'john#example.com';
$recepientName = 'John Doe';
// Get Store ID
$storeId = Mage::app()->getStore()->getId();
// Set variables that can be used in email template
$vars = array('customerName' => 'customer#example.com',
'customerEmail' => 'Mr. Nil Cust');
$translate = Mage::getSingleton('core/translate');
// Send Transactional Email
Mage::getModel('core/email_template')
->sendTransactional($templateId, $sender, $recepientEmail, $recepientName, $vars, $storeId);
$translate->setTranslateInline(true);
}

Resources