Jump to content

Add item to cart using URL


Recommended Posts

My site currently uses 3.x and Nexus to sell themes, however instead of using the Nexus storefront to browse products, I've coded my own external php pages (not integrated with IP.Board). A visitor simply clicks the green "Download" link on my website, and the product is added to their cart in nexus. They are also redirected to their cart after clicking the link.

I'm currently using this code to add a product to my 3.x Nexus cart:

<a href='http://www.site.com/forums/buy_skin.php?id=10'>Purchase theme</a>

The code which powers the link is:


define( 'IPS_PUBLIC_SCRIPT', 'index.php' );
define( 'IPB_THIS_SCRIPT', 'public' );
require_once( './initdata.php' );

require_once( IPS_ROOT_PATH . 'sources/base/ipsRegistry.php' );
require_once( IPS_ROOT_PATH . 'sources/base/ipsController.php' );

$reg = ipsRegistry::instance();

if ( $_GET['id'] )
	@header("Location: " . str_replace( '&', '&', ipsRegistry::$settings['base_url'] ) . 'app=nexus&module=payments&section=store&do=add&id=' . intval( $_GET['id'] ) . '&k=' . $reg->member()->form_hash );
	die("No ID passed");



I'd like to upgrade to 4.x. So my question is, how would I achieve the same result with 4.x and Commerce?

I'm not sure if this is a useful starting point, but I'm using the following code with 4.x to change the theme based on an id in the URL (using a similar URL to the one I posted above). The Commerce solution may be similar to this, but my knowledge is super limited so I'm not entirely sure:


$path = '';
$_GET['app'] = 'core';
$_GET['module'] = 'system';
$_GET['controller'] = 'theme';

require_once $path . 'init.php';
if (\IPS\Request::i()->id)
    $_SERVER['HTTP_REFERER'] = '';
    $disp = \IPS\Dispatcher\Front::i();
    \IPS\Request::i()->csrfKey = \IPS\Session::i()->csrfKey;
    die("No ID passed");


Thanks in advance for any help! ^_^

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...