Hi,
For the first code, I've never done several calls to update in one PHP script. When there are several products to add, HikaShop will add them all at once.
So maybe that's the reason the other products are not added ?
You could do it like that:
$data = array(
$CourseID => $Duration
);
if($IncludeRegFee==1) {
$RegFee = $this->data("english_registration_fee",9);
$data[$RegFee] = $Duration;
}
$class->update($data, $Duration, true, true);
In the second code, the issue is that you need to provide it an array of arrays:
$class->addProduct($cart_id,array(array('id' => $RegFee, 'qty' => $qty)));
That way, you can pass several products:
$class->addProduct($cart_id,array(array('id' => $RegFee, 'qty' => $qty), array('id' => $AdmFee, 'qty' => $qty)));
Also, I'm thinking the issue might be something else completely and you don't know about it because you don't check the messages provided by the system.
if you do:
$cart = $class->get($cart_id);
var_dump($cart->messages);
before the exit, you'll get the potential error messages.
One possibility I can think of is that you didn't set any price in your options, and you have the "Display add to cart button for free products" setting turned off in the Hikashop configuration. In that case, the system won't allow adding to the cart products without a price set.