Answers for ""codeigniter 4" cart"

PHP
0

codeigniter.com cart

<?php echo form_open('path/to/controller/update/method'); ?>

<table cellpadding="6" cellspacing="1" style="width:100%" border="0">

<tr>
        <th>QTY</th>
        <th>Item Description</th>
        <th style="text-align:right">Item Price</th>
        <th style="text-align:right">Sub-Total</th>
</tr>

<?php $i = 1; ?>

<?php foreach ($this->cart->contents() as $items): ?>

        <?php echo form_hidden($i.'[rowid]', $items['rowid']); ?>

        <tr>
                <td><?php echo form_input(array('name' => $i.'[qty]', 'value' => $items['qty'], 'maxlength' => '3', 'size' => '5')); ?></td>
                <td>
                        <?php echo $items['name']; ?>

                        <?php if ($this->cart->has_options($items['rowid']) == TRUE): ?>

                                <p>
                                        <?php foreach ($this->cart->product_options($items['rowid']) as $option_name => $option_value): ?>

                                                <strong><?php echo $option_name; ?>:</strong> <?php echo $option_value; ?><br />

                                        <?php endforeach; ?>
                                </p>

                        <?php endif; ?>

                </td>
                <td style="text-align:right"><?php echo $this->cart->format_number($items['price']); ?></td>
                <td style="text-align:right">$<?php echo $this->cart->format_number($items['subtotal']); ?></td>
        </tr>

<?php $i++; ?>

<?php endforeach; ?>

<tr>
        <td colspan="2"> </td>
        <td class="right"><strong>Total</strong></td>
        <td class="right">$<?php echo $this->cart->format_number($this->cart->total()); ?></td>
</tr>

</table>

<p><?php echo form_submit('', 'Update your Cart'); ?></p>
Posted by: Guest on November-24-2020
0

"codeigniter 4" cart

function cart(bool $getShared = true)
{
    return \Config\Services::cart($getShared);
}
Posted by: Guest on December-09-2020
0

"codeigniter 4" cart

// Call the cart service using the helper function

$cart = cart();



// Insert an array of values

$cart->insert(array(

   'id'      => 'sku_1234ABCD',

   'qty'     => 1,

   'price'   => '19.56',

   'name'    => 'T-Shirt',

   'options' => array('Size' => 'L', 'Color' => 'Red')

));



// Update an array of values

$cart->update(array(

   'rowid'   => '4166b0e7fc8446e81e16883e9a812db8',

   'id'      => 'sku_1234ABCD',

   'qty'     => 3,

   'price'   => '24.89',

   'name'    => 'T-Shirt',

   'options' => array('Size' => 'L', 'Color' => 'Red')

));



// Get the total items

$cart->totalItems();



// Remove an item using its `rowid`

$cart->remove('4166b0e7fc8446e81e16883e9a812db8');

 

// Clear the shopping cart

$cart->destroy();



// Get the cart contents as an array

$cart->contents();
Posted by: Guest on December-09-2020
0

"codeigniter 4" cart

public static function cart($getShared = true)
{
        if ($getShared) {
            return static::getSharedInstance('cart');
        }
        return new \App\Libraries\Cart();
 }
Posted by: Guest on December-09-2020

Code answers related to ""codeigniter 4" cart"

Browse Popular Code Answers by Language