Magento: Category Lock/Warning or T&C - magento

I wonder if there is a way to add a Warning/Advisory or Terms & Conditions (preferably) to a category or a landing page to warn users about adult content. On the shop I'm working on there is an "Adult Section" Category for Erotic Toys, Lingerie, cosplay, etc. and I need to warn users about such content before they access the section in case they're less than 18.
I've searched the web and only found paid extensions which I cannot afford. Does anyone know how to do this?
I'm using Magento CE 1.7.
Thanks,
EDIT:
Ok, so I've been trying to figure out how to do this and I just figured that the best way to do it would be to just create a Category Landing Page and adding a java script for T&C redirect to the page I want it to.
This is the code I would use for the Category Landing Page with blank content would be this.
<?php $_categories = $this->getCurrentChildCategories() ?>
<?php $_collectionSize = $_categories->count() ?>
<div>
<?php $i=0; foreach ($_categories as $_category): ?>
<?php
$layer = Mage::getSingleton(‘catalog/layer’);
$layer->setCurrentCategory(Mage::getModel(‘catalog/category’)->load($_category->getId()));
$helper = Mage::helper(‘catalog/category’);
?>
Then I found a code snippet that would redirect the user to a page of my liking after clicking accept but I'm not sure how to implement it and/or if this is the best choice. Here's the code.
<form action="url-to-go-to" method="GET" onsubmit="return checkCheckBox(this)">
I accept: <input type="checkbox" value="0" name="agree">
<input type="submit" value="Continue">
<input type="button" value="Exit" onclick="document.location.href='BACKTOWHAT.html';">
</form>
<script type="text/javascript">
<!--
function checkCheckBox(f){
if (f.agree.checked == false )
{
alert("Please tick the box to continue");
return false;
} else
return true;
}
-->
</script>
Now I was thinking that it would be best to just create a simple CMS page and point the category on the top menu to that page and once they have agreed and clicked on continue, they could be taken to the actual category by simply pointing the 'onclick' to the URL of the actual category.
Not sure if this is the best way but it's the only way I could come up. The other way I thought of would've required me to take the "agreements" during checkout that already comes with magento and make an extension that would allow me to place it on any page and call the "Agreement ID" from the Sales/Terms and Conditions tab but I don't know how to actually do that, it was just a thought.
If anyone has a better solution, I'd be happy to hear it.

I would add some sort of JavaScript that shows a div over the top of the whole page, that will create a session cookie when you accept to watch the category. Otherwise, make a back() in the history navigation. This way you don't need another page, just JS.
On another note, could you please post the extensions you found that do this?

Related

Preserving language session ID from one domain to the next

I have two multi-lingual web sites. The main site and the shop site. On the main site detail page there is a "find in store" button. When the button is pressed, no matter what the language was set to on the main page, the shop page will open the product detail page in the default language (expected).
Is there a way to pass the session setting for language when redirecting to the shop site?
<?php
if (!session_id()) session_start();
if (!isset($_SESSION['languageID'])) {
$_SESSION['languageID'] = 1;//default value
}
?>
<?php
if (array_key_exists('german_x', $_POST)) {
$_SESSION['languageID'] = 1;
} else if (array_key_exists('english_x', $_POST)) {
$_SESSION['languageID'] = 2;
} else if (array_key_exists('french_x', $_POST)) {
$_SESSION['languageID'] = 3;
} else if (array_key_exists('spanish_x', $_POST)) {
$_SESSION['languageID'] = 4;
}
?>
The URL of the find in store button looks like this:
<input type="submit" name="goToShop" value="Find in store" />
Didn't get any answers, so I got creative. Maybe not the best or conventional way to go, but here is what I did, maybe it will help someone else:
Some of the language content is done with includes. I created an html page with a link to the detail page, that had the language session set in the desired language. So, while the English session was running, it would call detail_en.php, while Spanish it would call detail_es.php etc.
This is what the link looks like:
<input type="submit" name="goToShop" value="<?php echo $row_rscontent13['description15']; ?>" />

Joomla 2.5 frontend pagination clicking on next button not working

I am using joomala 2.5 and developed my own component for showing table data in front end and added pagination. I'm getting pagination links, after clicking on the links 'next', 'prev' nothing happens.
What may be the problem?
In view.html.php I've added
$this -> pagination = $this->get('Pagination');
In default.php I've added
<div class="pagination">
<?php echo $this->pagination->getListFooter(); ?>
</div>
You haven't mentioned what you have done in you components model file. My advoice to you is just read this document carefully http://docs.joomla.org/J1.5:Using_JPagination_in_your_component & you will be easily apply pagination. The doc is perfect & its very simple to use pagination in Joomla.
Thank you.
Put your pagination buttons inside a tag and make sure the action url points to the same view (e.g. action = 'index.php?option=com_component&view=listview')
<form action=""...>
<div class="pagination">
<?php echo $this->pagination->getListFooter(); ?>
</div>
</form>

Yii: Already add or edit record but view not update

I got a problem about browser cache when I already add/edit record in database. The data in database changed but in view not change. I must press F5 in browser for refresh that page and it'll show updated data.
Please guide to me how to solve this problem, Thanks.
Sorry I forgot to told you guys, In my application has two part.
Admin part (Backend) for add/edit data. (There's not any problem in
this part)
Front part for show data to viewer (Problem here! After
add/edit record in Admin part, this part not changed. I must refresh
page to see update)
This's my relevant code in Front part.
In Controller
class ProductController extends Controller
{
public function actionIndex()
{
$products = Product::model()->getProductList(); // use findAll() method
$this->render('index', array('products' => $products));
}
}
In Model
class Product extents CActiveRecord
{
/*
*
* The other code that generated by Gii
*
*/
public function getProductList()
{
return $this->findAll();
}
}
In View
<html>
<body>
<ul class="thumbnails thumbnails-product">
<?php foreach ($products as $product): ?>
<li class="span3" style="margin-left:0px;">
<div class="thumbnail">
<img class="img-thumb" src="../images/<?php echo $product->PDT_IMG" />
<?php echo CHtml::link($product->PDT_NAME, array('product/view/' . $product->PDT_ID)); ?>
<span class="price"><?php echo $product->PDT_PRICE; ?></span>
</div>
</li>
<?php endforeach; ?>
</ul>
</body>
</html>
If you want something to update on-the-fly, I think you're looking for in place editing.
You could take a look at this extension which does that for you.
Especially this part.
May be this can help you out:
Real-time display of server push data using Server-Sent Events (SSE)
this is server push technique by which we can fetch data in every changes made automatically and also after a certain time.
The problem has been solved.
I just add
header ("Cache-Control: no-cache, must-revalidate");
header ("Pragma: no-cache");
Everytime that view load, it'll reread page and doesn't keep any cache.

loading magento cart block to a drop down panel

Can any one please help me to load magento cart block into a drop down box. To be more specific, the module title or a menu should display some thing like 'my basket' and there should be a message of number of items in the cart below 'my basket'. When the user hovers the menu the drop down box should display the content of the cart/sidebar.phtml.Can anyone please suggest me how I can achieve this?
Thanks in advance.
I am doing this for a site I am working on. Unfortunately, I have had to do this through a static block...but it seemed to work without any issues. This is working for me, have a play and see how you go.
The CSS is pretty simple and is they key to showing and hiding the drop down itself.
CSS
// this is the panel where the cart is displayed
DIV#cart-panel {
width:100px; //arbitary width
position:absolute; // need this so that it doesn't interfere with the layout
display:none; // hides the block
z-index:200; // makes it way it in front of other content
}
#cartBtn:hover #cart-panel { display: block; } // basically, when you hover over the cartBtn, the cart-panel displays
Static Block contains
<li id="myCartBtn">
My Cart
{{block type="checkout/cart_sidebar" template="checkout/cart/sidebar.phtml"}}
</li>
Then in my sidebar.phtml, I just make sure there is a div with id="cart-panel" in it, surrounding the cart itself, instead of the <div class="block block-cart">
<?php if ($this->getIsNeedToDisplaySideBar()): ?>
<div id="cart-panel">
...
</div>
<?php endif; ?>
Then, finally, I put the static block into the template where I need it
check Fatdivision AJAX Quick Cart article.
Create an AJAX Quick Cart for Your Magento Theme

Automatic update the cart on proceed to checkout is clicked

I am using magento. I want to automatically update the cart on proceed to checkout button is clicked. so that my values are saved without the effort to click on update cart. Ajax based solution is also acceptable.
I was able to "fix" it by changing the behaviour of the Checkout button.
Instead of just going to the checkout page, it submits the cart form. In order to have it redirect to the checkout afterwards, it makes sure that redirect_url is set right before the submission.
This is the code I put in template/checkout/onepage/link.phtml:
<?php if ($this->isPossibleOnepageCheckout()):?>
<script type="text/javascript">
// <![CDATA[
function updateAndGoto(url) {
var cartForm = $$('.cart form').first();
var action = cartForm.readAttribute('action');
if (action.indexOf('return_url') < 0) {
var glue = action.indexOf('?') < 0 ? '?' : '&';
action += glue + 'return_url=' + url;
cartForm.writeAttribute('action', action);
}
cartForm.submit();
}
// ]]>
</script>
<button type="button" title="<?php echo $this->__('Proceed to Checkout') ?>" class="button btn-proceed-checkout btn-checkout<?php if ($this->isDisabled()):?> no-checkout<?php endif; ?>"<?php if ($this->isDisabled()):?> disabled="disabled"<?php endif; ?> onclick="updateAndGoto('<?php echo $this->getCheckoutUrl() ?>');"><span><span><?php echo $this->__('Proceed to Checkout') ?></span></span></button>
<?php endif?>
This seems like a very poor idea. Customers have expectations about how a cart should function, especially with an update button being present. If you change that functionality so that a customer cannot see that their update was not made until they go through the entire checkout process, they may not order what they had intended, or they may not order at all. Surprising the user is almost always a bad idea.
Otherwise, short of AJAX, you'd want to make the "Checkout" button part of the same form that wraps the cart for updates.
Hope that helps!
Thanks,
Joe

Resources