Jump to content

Recommended Posts

Posted (edited)

Hello everyone;

I'm trying to obtain the IDs of products for my own pages. However, I think I need the help of more experienced friends on how to accomplish this. Thanks to everyone who helps me find a way to add a product directly to the cart in the PHP file below.

When I go to this address from the browser, it goes to the cart page, but no product is added.

http://www.mysite.com/card.php?id=2

<a href="http://www.mysite.com/card.php?id=2">Add to cart</a>

<?php

$_SERVER['SCRIPT_FILENAME'] = __FILE__;
$path = '';
$_GET['app'] = 'nexus';
$_GET['module'] = 'store';
$_GET['controller'] = 'cart';

require_once $path . 'init.php';
if (\IPS\Request::i()->id)
{
    $_SERVER['HTTP_REFERER'] = '';
    $disp = \IPS\Dispatcher\External::i();
    \IPS\Request::i()->csrfKey = \IPS\Session::i()->csrfKey;
    $disp->run();
}
else
{
    die("No ID passed");
}
exit();
Edited by OsmanK
  • Recently Browsing   0 members

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