GithubHelp home page GithubHelp logo

olegforce / plugin_newsletter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from salesforcecommercecloud/plugin_newsletter

0.0 0.0 0.0 15 KB

This is a sample repository to show how to implement a simple form in SFRA.

JavaScript 100.00%

plugin_newsletter's Introduction

README

plugin_newsletter

This is a sample repository to show how to implement a simple form in SFRA. The plugin demonstrates several B2C Commerce concepts in one easy to follow example:

  1. B2C Commerce form definition: newsletter.xml
  2. Form ISML using attributes from the form definition
  3. Form client-side javascript to submit form to controller and handle errors back from controller
  4. Controller to show the form and handle submission
  5. Implementation of CSRF (Cross Site Request Forgery) protection in controller and ISML file
  6. Custom object (aka CO) creation (requires import of CO metadata, which is included)
  7. Transaction handling in controller (saves data to persistent CO)
  8. Use of a middleware event in controller: BeforeComplete
  9. Use of Logger class to log an error when CO has not been defined
  10. Sending validation error message back to the client-side

Getting Started

  1. Clone this repository.
  2. Install npm dependancies npm install.
  3. Open package.json file and modify paths.base property to point to your local app_storefront_base cartridge.
  4. Run npm run compile:js to create client-side assets. There is no scss to compile.
  5. Run npm run uploadCartridge if you have a properly configured dw.json with login credentials to your SB
  6. In Business Manager, add the plugin_newsletter cartridge to your site's cartridge path. The path must contain the SFRA base cartridge app_storefront_base.
  7. In Business Manager, under Administration > Site Development > Import & Export, upload and import the newslettersubscription_co_metadata.xml. This custom object definition is required for the demo to work.
  8. On a browser, invoke the Newsletter-Show route for in your site. For example: https://<your_sandbox>/on/demandware.store/Sites-<your_site>-Site/en_US/Newsletter-Show.

NPM scripts

Use the provided NPM scripts to compile and upload changes to your Sandbox.

Compiling your application

  • npm run compile:js - Compiles all js files and aggregates them.
  • npm run uploadCartridge - Uploads the cartridge to your sandbox. A properly configured dw.json file is required (see initial commit for this repo to find a sample. Modify to point to your sandbox and active version).

Testing

Since this is a demonstration plugin, there are no automated tests.

Contributing

Since this is a demonstration plugin, suggestions for improvement are welcomed. Please contact [email protected]. Only properly commented code will be accepted.

plugin_newsletter's People

Contributors

jorgehernandezsf avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.