Code Monkey home page Code Monkey logo

wfcart's Introduction

WFcart

Free Open Source Library / Package Shopping Cart For Codeigniter 4

Cara Install

  1. Masuk ke dalam direktory project/app/ThirdParty
cd app/ThirdParty
  1. Clone Repository
git clone https://github.com/wildanfuady/WFcart.git
  1. Aktifkan autoload. Silahkan buka file app/Config/Autoload.php dan cari kode berikut ini:
$psr4 = [
	'App'         => APPPATH,                // To ensure filters, etc still found,
	APP_NAMESPACE => APPPATH,                // For custom namespace
	'Config'      => APPPATH . 'Config'
];

Tambahkan 1 baris kode di bawah ini:

$psr4 = [
	'App'         => APPPATH,                // To ensure filters, etc still found,
	APP_NAMESPACE => APPPATH,                // For custom namespace
	'Config'      => APPPATH . 'Config',
	'Wildanfuady' => APPPATH . 'ThirdParty/WFcart/Wildanfuady'
];

Cara Penggunaan

  1. Tambahkan kode berikut sebelum nama class di Controller
use Wildanfuady\WFcart\WFcart;

class Cart extends BaseController
{
    // code
}
  1. Pada function construct, tambahkan baris kode di bawah ini:
public function __construct() {

	$this->cart = new WFcart();

}
  1. Untuk mendapatkan data total keranjang belanja, gunakan perintah di bawah ini:
$this->cart->totals();
  1. Untuk mendapatkan data total belanja ( quantity * sub total), gunakan perintah di bawah ini:
$this->cart->count_totals();
  1. Untuk memasukan suatu product ke dalam keranjang belanja, gunakan perintah di bawah ini:
$id = 1; // ambil dari kode product
$item = [
	'id'		=> $id,
	'name'		=> 'Product 1,
	'price'		=> 1000,
	'photo'		=> 'product1.jpg',
	'quantity'	=> 1
];
$this->cart->add_cart($id, $item);
  1. Untuk menghapus suatu product berdasarkan id di dalam keranjang belanja, gunakan perintah di bawah ini:
$this->cart->remove($id);
  1. Untuk mengupdate keranjang belanja, silahkan gunakan perintah di bawah ini:
$this->cart->update();

Tutorial Pendukung

  1. https://ilmucoding.com/shopping-cart-codeigniter-4/ (Part 1)
  2. https://ilmucoding.com/cart-codeigniter-4/ (Part 2)

wfcart's People

Contributors

wildanfuady 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.