Enhancement #1093

Add the ability to have custom code in basket and order (recapitulation) view

Added by Blatti Yves over 3 years ago. Updated over 3 years ago.

Status:ClosedStart date:08/25/2015
Priority:HighDue date:
Assignee:-% Done:

100%

Category:SHOP
Target version:4.3.2
Sponsor: Ergonomic impact:

No impact for users without plugin.

Functional impact:

An integrator can code a plugin to add custom code in SHOP views having a map.


Description

Add the ability to have custom code in basket and order (recapitulation) view.
The idea is to add a custom plugin trigger to get custom JS code in views having a map.
This would allow integrator to add code in basket map etc. For example: custom layer switcher, custom search box...

History

#1 Updated by Van Hoecke Hélène over 3 years ago

  • Status changed from Request For Comments to Accepted
  • Assignee changed from Technical Committee to Blatti Yves

TC has validated this enhancement

#2 Updated by Blatti Yves over 3 years ago

  • Status changed from Accepted to Affected

#3 Updated by Blatti Yves over 3 years ago

  • % Done changed from 0 to 50

Basket Plugin : rev. 9048

#4 Updated by Blatti Yves over 3 years ago

  • Status changed from Affected to Resolved
  • % Done changed from 50 to 100

Recap plugin : rev. 9056

#5 Updated by Blatti Yves over 3 years ago

Since there's thwo structures of views:
  • The basket view
  • The "recap" views (order, validation & request)

Each have it's plugin type!

If one want's to have a JS plugin for it's SHOP:

For basket:
- create a plugin in folder easysdi_basket_script
- the plug has to offer a method public function getBasketScript() that returns javascript as String
For recaps:
- create a plugin in folder easysdi_recap_script
- the plug has to offer a method public function getRecapScript($context) that returns javascript as String
- context var contains the 'viewType' constant (see easysdi_shop_helper) : usage example if(Easysdi_shopHelper::ORDERVIEW_ORDER == $context->viewType)
Notes:
- this mechanism does not alter current users if they're not using plugins
- multiple plugins can be loaded of each types, scripts are concatenated.
- plugins can add interact with DOM document (for example: $document->addScript(Juri::base(true) . '/components/com_asitvd_simpleshop/libraries/autocomplete/jquery.autocomplete.min.js');)

A plugin example: file joomlaROOT/plugins/easysdi_recap_script/asitvdrecap/asitvdrecap.php

defined('_JEXEC') or die;

//shop helper for view types constants
require_once JPATH_SITE . '/components/com_easysdi_shop/helpers/easysdi_shop.php';

class PlgEasysdi_recap_scriptAsitvdrecap extends JPlugin {
    public function getRecapScript($context) {
        //only display in 'order' view (client view)
        if (Easysdi_shopHelper::ORDERVIEW_ORDER == $context->viewType) {
            //add some JS files
            $document = JFactory::getDocument();
            $document->addScript(Juri::base(true) . '/components/com_asitvd_simpleshop/libraries/autocomplete/jquery.autocomplete.min.js');
            $document->addScript(Juri::base(true) . '/plugins/easysdi_recap_script/asitvdrecap/asitvdrecap.js');

            //run the initialisation method of asitvdrecap.js
            return 'asitvdrecapInit();';
        } else {
            //no script for other views
            return '';
        }
    }

}

#6 Updated by Blatti Yves over 3 years ago

  • Status changed from Resolved to To merge
  • Assignee changed from Blatti Yves to Van Hoecke Hélène

#7 Updated by Van Hoecke Hélène over 3 years ago

  • Target version set to 4.3.2

#8 Updated by Van Hoecke Hélène over 3 years ago

  • Status changed from To merge to Closed

#9 Updated by Van Hoecke Hélène over 3 years ago

  • Assignee deleted (Van Hoecke Hélène )

Also available in: Atom PDF