Append Content in cs cart thank you page? - cs-cart

How to append content after order submit with my custom database
table information via addon. Can you please add detailed explanation about hooks for both php and tpl hook for order submit in cs cart.
I find out order.post.tpl via addon hooks in docs example.

#PHP
file
app/addons/my_changes/controllers/frontend/checkout.post.php
content:
<?php
if ( !defined('BOOTSTRAP') ) { die('Access denied'); }
if($mode == 'complete' && !empty($_REQUEST['order_id'])){
/* add your code here */
}
#TPL
file design/themes/[THEME_NAME]/templates/addons/my_changes/hooks/checkout/order_confirmation.post.tpl
PS: The implementation is done base on My Changes add-on

Related

Wordpress submit post content from front-end with Ajax

I am generating my own Wordpress template and would like to give users a front-end form (so they don't have to log in to the wordpress dashboard) to submit some post content. I've got everything working, thanks to this tutorial - but I'd like to make one enhancement. Currently when the user presses submit the data is stored in wordpress and they are then redirected to a fixed URL of my choosing. Rather than this I would like to simply clear the form data and display a confirmation message - I guess via AJAX? I know there are built in AJAX capabilities in wordpress, but I've never really used it. Can anyone help me out?
The part of the code that submits the data to Wordpress and provides the URL to be redirected is copied below. I assume I wil need to make a change here?
$post_id = wp_insert_post($post_information);
if($post_id)
{
wp_redirect( '/thanks' );
exit;
}
You could simply redirect to the current page with get_permalink():
if ( $post_id )
{
wp_safe_redirect( add_query_arg( array( 'thanks' => '1' ), get_permalink() ) );
exit;
}
To display a message in the template, check the query arg:
if( isset( $_GET['thanks'] ) && '1' == $_GET['thanks'] )
echo '<p class="success">Thanks!</p>';
if you need more featuredone means, try this,
http://kvcodes.com/2014/02/front-end-post-submission-wordpress/

You are not authorised to view this resource - Joomla

I am using joomla 2.5.9 version, and I would like Joomla to redirect me to the login page if I am not logged in when i click an article which the Permission Access is for Registered only, but instead Joomla returns me this message: You are not authorised to view this resource.
And I dont see any reason why joomla by default havent made it redirect to login page.
Thanks
This doesn't answer your exact question, but I think it's a good workaround. I'm working on the same issue. My approach at the moment is to check the messages for the "not authorised" string, and then set a flag based on that. You can then check that flag anywhere in template and either redirect, or just choose to optionally show the login form.`
/* get message from app */
$app = JFactory::getApplication();
$messages = $app->getMessageQueue();
/* set login flag to 0 */
$showlogin = 0;
/* if there is a message set... */
if (isset($messages[0])) {
/* loop through messages and check for the "not authorised" string */
foreach ($messages as $msg) {
if ($msg["type"] == "error" && strpos($msg["message"], "not authorised") ) {
/* if found, update login flag */
$showlogin = 1;
}
}
}
/* include in template body - you could redirect here instead of including login form */
if ($showlogin) { ?>
<jdoc:include type="modules" name="login-form" style="none" />
<?php } ?>
`
this happens when you try to access an article which is not visible, but the category is publically visible.
Seems like it is not considered a bug, but I think its a pretty unexpected "feature".
To fix this you can edit:
joomla/components/com_content/views/article/view.html.php
// Check the view access to the article (the model has already computed the values).
if ($item->params->get('access-view') == false && ($item->params->get('show_noauth', '0') == '0'))
{
$app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'), 'error');
$uri = urlencode(base64_encode(JURI::getInstance()->toString()));
JFactory::getApplication()->redirect(
JRoute::_('index.php?option=com_users&view=login&return='. $uri, false)
);
return;
}
This will show the login screen and return to the article after a succesfull login.
If you dont want to edit the core file (because you want to update your system), you have to create a system plugin to override this.

JToolbar::save() redirection

I'm going through the Joomla 2.5 tutorial to build a custom component. Now I'm facing an issue on the redirection after using JToolbar::save() or JToolBarHelper::cancel for that matter. By default Joomla wants to redirect to the default layout (from the edit layout). However I don't want it to do that. I want it to redirect back to another view. In Joomla 1.5 I would have done this through adding the function into the controller - something like
function cancel()
{
//redirects user back to blog homepage with Cancellation Message
$msg = JText::_( 'COM_BLOG_POST_CANCELLED' );
$this->setRedirect( 'index.php?option=com_jjblog&view=jjblog', $msg );
}
Now that works beautifully for the cancel function, however for save this is a much more complex thing. If I want to overwrite the url do I have to redirect the controller to the model and then write in all the code for the model interaction? Because that seems slightly excessive just for a url redirection like you would in Joomla 1.5?
Hope you have added the save toolbar code with the proper controller name like this
JToolBarHelper::save('controllerName.save');
Create a save function in appropriate controller.
Add the task in the form
Finnally make sure you have added form action withthe corresponding component name.
You can try this-
In the controller firstly you call the parent save function than redirect to url.
function save(){
parent::save();
$this->setredirect('index.php?option=com_mycomponent');
}
OK it didn't need to $this->setRedirect at all. Just needed me to change the value to
protected $view_list = 'jjBlog';
which then sets the redirects of everything back to that list view.
Source link for this is here.
Thanks for all the responses though!!
view.html.php
protected function addToolbar ()
{
JRequest::setVar ('hidemainmenu', false);
JToolBarHelper::title (JText::_ ('Configuration'), 'configuration.gif');
JToolBarHelper::save($task = 'save', $alt = 'JTOOLBAR_SAVE');
}
controller.php
public function save()
{
$mainframe = JFactory::getApplication();
$mainframe->enqueueMessage (JText::_ ('COM_SOCIALLOGIN_SETTING_SAVED'));
$this->setRedirect (JRoute::_ ('index.php', false));
}
I think you can use
global $mainframe;
$mainframe->redirect("index.php?option=com_user&task=activate&activation=".$activation);
If you are overriding joomla's default save function in your custom component like
function save( $task = 'CustomSave', $alt = 'Save' ) // or even same name Save
Inside your controller you can use the CustomSave as the task and use $mainframe for redirect.
or
$mainframe = &JFactory::getApplication();
$mainframe->redirect("index.php?option=com_user&task=activate&activation=".$activation);
Hope this may help you..

Magento shopper theme mulitple cart-top-title on "add to cart"

I'm using the Magento Shopper Theme (http://shopper.queldorei.com/).
When I add a product to my shops cart, it adds multiple elemtns of
<div class="cart-top-title">
<a href="https://droppinstudio.dk/horsepony/index.php/checkout/cart/" class="clearfix">
<span class="icon"></span>Cart</a></div>
I've figured out that it is the jQuery that makes the mistake here:
function setLocationAjax(url, id)
{
...
if (data.status != 'ERROR' && $('.cart-top-container').length) {
$('.cart-top-container').replaceWith(data.cart_top);
}
...
}
Does anybody have a good idea of what to do to fix this?
You should have a look into the CartController, and change the response variable (data.cart_top).
The location of CartController depends on the module the theme uses. The core CartController is located in app/code/core/Mage/Checkout/controllers/CartController.php.
Hope this helps.
Thank you Erwin, that helped me figure out what is wrong.
The CartController is located in app/code/local/Excellence/Ajax/controllers/ and is actually named IndexController.php.
Line 52-54 sets the data.cart_top response:
$sidebar_header = $this->getLayout()->getBlock('cart_top')->toHtml();
Mage::register('referrer_url', $this->_getRefererUrl());
$response['cart_top'] = $sidebar_header;
A fix could be to change the way the cart_top block is designed, and remove the 'cart-top-title' from cart_top.phtml and put it in a file of its own and include it in header.phtml.
Turns out the acutal replacement happens in line 85 of ajaxcart.js (function setLocationAjax).
A quick fix for me was to delete the div with jQuery like so:
if (data.status != 'ERROR' && $('.cart-top-container').length) {
$('.cart-top-title').remove();
$('.cart-top-container').replaceWith(data.cart_top);
}
js file here: skin/frontend/default/shopper/js/ajaxcart/ajaxcart.js
cart_top.phtml here: app/design/frontend/default/shopper/template/checkout/cart/cart-top.phtml
header.phtml here: app/design/frontend/default/shopper/template/page/html/header.phtml

Where is Itemid used to flag active menu item in Joomla 2.5.6?

Can anyone please help me with the process flow through which the Joomla Itemid parameter ends up being the highlighted menu item?
I have embedded a 3rd party application in Joomla and by temporarily changing the php environment within the application.
I am able to get joomla html and insert the 3rd party html by replacing a token.
Simplified Code:
if ($_SERVER['REQUEST_METHOD'] == 'GET' ) {
$_SERVER['REQUEST_METHOD'] = '';
}
$_SERVER['REQUEST_URI'] = '/joomla/index.php?view=mycom&option=com_mycom&Itemid=103';
$_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF'] = '/joomla/index.php';
$_SERVER['QUERY_STRING'] = 'view=mycom&option=com_mycom&Itemid=103';
ob_start();
require_once '/joomla/index.php';
$joomlaHTML = ob_get_clean();
echo str_replace($replacementToken, $thirdPartyHTML, $joomlaHTML);
In v1.5.x, the menu item with ID 103 is properly highlighted but in v2.5.6, it isn't and the Home item is always highlighted. I think it used to be highlighted correctly in v1.6.x and earlier versions of 2.5.x as well but not sure.
I wanted to find how the process flows (where this is set) so I can see what tweaks I need to make.
DELETED WRONG INFO
Thanks Dayo! you saved my day with this:
// force highlight the external url menu item
$Itemid = JRequest::getVar('Itemid');
$menu = JSite::getMenu();
$menu->setActive($Itemid);
I don't fully understand the breadcrumb part, but I managed to get it working by editing my component's controller.php to read:
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// force highlight the external url menu item
$Itemid = JRequest::getVar('Itemid');
$menu = JSite::getMenu();
$menu->setActive($Itemid);
// force fix the breadcrumb
$app = JFactory::getApplication('site');
$pathway =& $app->getPathway();
$bcrumbs = &JPathway::getInstance('site');
// import Joomla controller library
jimport('joomla.application.component.controller');
/**
* MyCom Component Controller
*/
class MyComController extends JController
{
}
Look in the following File
Check the
/modules/mod_menu/mod_menu.php
File and you will see two functions has been called "getActive" and "getDefault"
Which can be find in following file
/libraries/joomla/application/menu.php
I think it can be customized easily now

Resources