문제

With Magento you can see a message, "Productname" is added to the cart.

I need this message too!

I use SimpleCart package as Modx Revolution webshop. (not simplecart.js)

Really don't know how to do this. I have a Snippet with this content which might be the right one where to add some code! http://pastebin.com/7A4Twhim

Does anyone knows howto?

(Below code didn't work)

<?php
if( isset($_POST) && isset($_POST['addcart']) && $_POST['addcart']=='Add' ) {
    return '<div class="message">The product is added to the basket</div>';
}
도움이 되었습니까?

해결책

Ok, you need to add in your snippet before this line

$url = $modx->makeUrl($redirectTo, '', '', $redirectScheme);

this:

setcookie('added_prod', $productId, time() + 60*60*24*30, '/'); // set cookie

and then create snippet [[!product_added]]

<?php
if (isset($_COOKIE) && isset($_COOKIE['added_prod']) && !empty($_COOKIE['added_prod'])) {
    $id_prod = (int) $_COOKIE['added_prod'];
    $resource = $modx->getObject('modResource',$id_prod);
    setcookie("added_prod", "", time()-3600); // unset cookie
    return '<div class="message">The product "'.$resource->get('pagetitle').'" is added to the basket</div>';
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top