
Learn to build a giveaway module as a custom opencart extension, including selecting a random winner from the database and packaging the module for sale on the extension marketplace.
Create a new, uniquely named table in the open cart database for a giveaway. Define fields like id (auto increment), description (255 chars), product, winner, and customer_id, then save.
Set up the OpenCart MVC structure by creating controller, model, and view extensions for the admin side, using language files and camel case naming.
Resolve permissions issues by ensuring the administrator group has access to the extension module via system users and user groups; update permissions, select all, save, then access the giveaway feature.
Create a home route by adding a controller function that loads the giveaway view, linking the url /giveaway/home to display the module page for users.
learn to pass data from an OpenCart controller to a view by loading a view template, organizing admin templates, and configuring the response output.
Pass data into an OpenCart view using a data array and the load view method, including a heading title, header, column left, and footer in the template.
Build an HTML page layout with a title, a description input with an id, and a Bootstrap-styled primary button; add a full-width results table to list drawings.
OpenCart creates a few test customers in a blank installation to enable random customer selection. Follow along to add several customers and see the four Beatles shopping in the store.
Post data to a controller with ajax by creating a submit function that sends description and product id, handles admin token, and tests the response with a simple echo.
Learn to save user input through the OpenCart model by creating a public function, escaping inputs, and inserting records with a database query, while validating types and handling timestamps.
Load the model and query the database to retrieve giveaways, return the rows to the controller, and render each entry in the view with its description, product, and customer data.
Create a pick a winner button that selects a random customer when no winner exists, displays the winner's ID, and uses data attributes, closest table row, and ajax.
Learn how to implement a select-winner flow in opencart 2.3.0.2 by posting data, loading models, fetching and shuffling customers, and saving the winner to the giveaway.
Display winner information for Opencart 2.3.0.2 module development by example by resolving giveaway customer IDs to names and emails, loading the customer model, and linking to customer profiles.
Display product information by loading the catalog product model and checking customer id and product id before rendering, avoiding undefined index errors and handling missing data gracefully with sensible defaults.
Implement a delete button in the OpenCart 2.3.0.2 module, add an action column, wire click events to remove a giveaway by id and reload page, and update giveaway date.
Learn how to swap views behind the scenes using AJAX and package your Opencart module, including database integration and left-column navigation for easy extension discovery in the marketplace.
Refactor the application by extracting the changing table into a separate template and loading it on demand to update results in place without a full page reload.
Advance refactoring part 2 demonstrates updating page without reloads by wiring the create drawing button to the results function, updating data from the database, and refreshing the table via JavaScript.
Refactor your code to delegate click events to the document, enabling dynamic pick winner and delete actions in the OpenCart module without page refresh, and package the sleek modern module.
Perform quick bug fixes before moving forward by verifying giveaways data exists and handling empty databases with a zero result, and implement existence checks to prepare for future stability.
Opencart is a free, open-source e-commerce platform. Its easy to install, easy to use, and full of features. A big part of Opencart is the Opencart Marketplace, where developers can share their custom extensions that will expand the functionality of an owner's opencart store. In this course, you will be taught by an industry professional with years of experience. You will learn how to create one of these custom opencart extensions step-by-step, so that you can begin developing like the pro's!
You'll learn ...
You'll be building a Give-Away module, which will allow the Administrator of the store to create a giveaway, assign a product to be given away, and have the system select a winner of the product! When you're done you'll know how to create the module from start to finish, as well as know how to package it up for distribution on the web!
Become an Opencart developer! Enroll today!