Forums / Setting Up Categories, Products, Attributes / Automatic message in checkout/shopping basket when certain items are selected

Automatic message in checkout/shopping basket when certain items are selected

Started by christospur on 13 Mar 2013, 8:56 AM · Views: 1,691

Results 1 to 11 of 11
13 Mar 2013, 8:56 AM
#1
christospur avatar

christospur

New Zenner

Join Date:
Sep 2012
Posts:
40
Plugin Contributions:
0

Automatic message in checkout/shopping basket when certain items are selected

Hello,

[Using 1.3.9h, upgrading organically]

I'm trying to set up a series of special order products on our site, and wish for a message saying something akin to:

"As there are some special order items in your basket, please note that the complete order shall be delivered within seven working days whilst we source your SO items - we endeavour to contact you within 24 hours of your order for a more precise update".

Is there a way to make a message come up only when selected items are chosen?

We've tried using the SO Products Module, but it didnt really work out for us, so wanting an alternative solution and we're just one message away. :frusty:

Thank you ZC :smartalec:

13 Mar 2013, 9:45 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Automatic message in checkout/shopping basket when certain items are selected

Are all of these special order products in one category?

Zen-Venom Get Bitten

13 Mar 2013, 10:08 AM
#3
christospur avatar

christospur

New Zenner

Join Date:
Sep 2012
Posts:
40
Plugin Contributions:
0

Re: Automatic message in checkout/shopping basket when certain items are selected

No, but could it be an option to put all 'special order' products into one master category and then 'link' the products individually to other categories?

13 Mar 2013, 11:13 AM
#4
christospur avatar

christospur

New Zenner

Join Date:
Sep 2012
Posts:
40
Plugin Contributions:
0

Re: Automatic message in checkout/shopping basket when certain items are selected

Sorry, by that I meant - in order to make this work based on a certain catagory, i could put all these products into one category with ease, so that could be a viable option.

13 Mar 2013, 6:18 PM
#5
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Automatic message in checkout/shopping basket when certain items are selected

Add an if statement to your templates tpl_product_info_display.php file
What ever the cat number for this cat is is what you will want to insert for cpath=65

  if (in_array($current_page_base,explode(cpath=65)) ) {
    <div id="specialOrder"  <?php echo "Your special order text.";
    ?> 
   </div>
  }

You can also add #specialOrder to your stylesheet if necessary for specific styling

Zen-Venom Get Bitten

29 Mar 2013, 12:37 PM
#6
christospur avatar

christospur

New Zenner

Join Date:
Sep 2012
Posts:
40
Plugin Contributions:
0

Re: Automatic message in checkout/shopping basket when certain items are selected

Hello,

I tried inserting the code, but no messages come up in my shopping basket or checkout for items chosen from the specific 'special order' category.

Am I meant to put the code in a specific place in the tpl_product_info_display.php

Please let me know :-)

29 Mar 2013, 12:50 PM
#7
fairestcape avatar

fairestcape

Totally Zenned

Join Date:
Mar 2008
Location:
Cape Town &amp; London (depends on the season)
Posts:
2,957
Plugin Contributions:
0

Re: Automatic message in checkout/shopping basket when certain items are selected

christospur:

Hello,

I tried inserting the code, but no messages come up in my shopping basket or checkout for items chosen from the specific 'special order' category.

Well it wouldn't appear in checkout or shopping cart, because the code is in tpl_product_info_display.php

christospur:

Am I meant to put the code in a specific place in the tpl_product_info_display.php

Please let me know :-)

The position of the message (in PRODUCT INFO PAGES) is determined by where it is placed in relation to other <!---bof xxxxxxxxxx --> <!--eof xxxxxxxxxx --> elements.

29 Mar 2013, 12:54 PM
#8
christospur avatar

christospur

New Zenner

Join Date:
Sep 2012
Posts:
40
Plugin Contributions:
0

Re: Automatic message in checkout/shopping basket when certain items are selected

I see... how can I get a message to appear in the shopping basket / checkout if certain items are chosen?

29 Mar 2013, 1:14 PM
#9
christospur avatar

christospur

New Zenner

Join Date:
Sep 2012
Posts:
40
Plugin Contributions:
0

Re: Automatic message in checkout/shopping basket when certain items are selected

Basically, I want to create a way for a message to come up in the shopping basket checkout (similar to the way that out of stock products have the message) for when certain products are chosen.

Please could you let me know how I can do this, as the Special Order module didnt quite work out.

1 Apr 2013, 4:07 AM
#10
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: Automatic message in checkout/shopping basket when certain items are selected

Two, maybe three steps:

  1. Upload the following as a new file to your site, as: /includes/classes/observers/class.observerProductsInCartMessage.php
<?php
/**
 * if the site is multilingual, copy the following define() statement to a new extra custom language file at /includes/languages/your_language_folder/extra_definitions/extra_products_message.php
 */
if (!defined('DEFINED_LANGUAGE_STRING_FOR_SPECIAL_PRODUCT_MESSAGE')) {
  define('DEFINED_LANGUAGE_STRING_FOR_SPECIAL_PRODUCT_MESSAGE', "As there are some special order items in your basket, please note that the complete order shall be delivered within seven working days whilst we source your SO items - we endeavour to contact you within 24 hours of your order for a more precise update.");
}


/**
 * If a customer adds certain products to their cart, display a special message on the shopping-cart page
 */
class observerProductsInCartMessage extends base
{
  /**
   * list the affected product IDs in this array, separating each with a comma:
   */
  var $products_array = array([B]10, 11, 12, 13[/B]);

  function __construct ()
  {
    $_SESSION['cart']->attach($this, array(
                    'NOTIFIER_CART_ADD_CART_END' ,
                    'NOTIFIER_CART_REMOVE_END',
                    'NOTIFIER_CART_GET_PRODUCTS_END'));
  }

  function update (&$class, $eventID, $paramsArray = array())
  {
    global $messageStack;
    static $alertSent = FALSE;
    /**
     * NOTE: The $alertSent variable is used to prevent displaying the message multiple times when multiple items are in the cart
     */
    $msgLocation = 'shopping_cart';
    foreach($this->products_array as $key) {
      if ($_SESSION['cart']->in_cart_check('products_id', $key) > 0) {
        if ($alertSent == FALSE) $messageStack->add_session($msgLocation, DEFINED_LANGUAGE_STRING_FOR_SPECIAL_PRODUCT_MESSAGE, 'caution');
        $alertSent = TRUE;
      }
    }
  }
}
  1. Upload the following as a new file to your site, as: /includes/auto_loaders/config.observerProductsInCartMessage.php
<?php
/**
 * @package observerscripts
 * @copyright Copyright 2003-2013 Zen Cart Development Team
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 */
$autoLoadConfig[200][] = array('autoType'=>'class',
                              'loadFile'=>'observers/class.observerProductsInCartMessage.php');
$autoLoadConfig[200][] = array('autoType'=>'classInstantiate',
                              'className'=>'observerProductsInCartMessage',
                              'objectName'=>'observerProductsInCartMessage');
  1. Optionally set up multilingual support by creating the extra_definitions language file as described in the beginning of the code in #1 above.

If it suits your needs, donations always welcome at https://www.zen-cart.com/donate

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

8 Apr 2013, 5:25 PM
#11
christospur avatar

christospur

New Zenner

Join Date:
Sep 2012
Posts:
40
Plugin Contributions:
0

Re: Automatic message in checkout/shopping basket when certain items are selected

Thank you - i've put in an application with my firm for a donation! :cool: