Skip to content

Instantly share code, notes, and snippets.

@rsanchez
Created September 2, 2011 17:11
Show Gist options
  • Save rsanchez/1189187 to your computer and use it in GitHub Desktop.
Save rsanchez/1189187 to your computer and use it in GitHub Desktop.
CartThrob add to cart outside of CT
<?php
$this->EE =& get_instance();
$this->EE->load->add_package_path(PATH_THIRD.'cartthrob/');
$this->EE->load->library('cartthrob_loader');
$params = array(
'product_id' => 37, //your entry_id
'item_options' => array(), //ie, 'product_size' => 'L',
'quantity' => 1,
'class' => 'product',
);
$item = $this->EE->cartthrob->cart->add_item($params);
//do this if you are in your own module action, as opposed to a cartthrob extension
$this->EE->cartthrob->cart->save();
Copy link

ghost commented Mar 26, 2014

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment