Zen Cart 1.5.7b
One-Page Checkout (One Page Checkout) - Version: v2.3.7
I've made some modifications to my site so that I can prevent specific products from being visible to customers from certain countries.
Whilst this works for the most part, I want to ensure that if a customer changes shipping address during checkout to a country that has restrictions, the restricted product is removed from the cart and a message advises the customer of this.
I've got shipping country detection working on main_page=checkout_one, but I'm struggling to find a way to remove the restricted product from the array.
I tried doing this
Code:
$selected_ship_country = $_SESSION['opc']->getAddressValues('ship')['country_id'];
foreach ($_SESSION['cart']->get_products() as $product) {
$check_for_restriction = $db->Execute("SELECT products_id
FROM " . TABLE_PRODUCTS . "
WHERE products_id = '" . $product['id'] . "'
AND restricted_country_id LIKE '%" . $selected_ship_country . "%'");
if ($check_for_restriction->RecordCount() > 0) {
remove($product['id']);
}
in the hope that calling the remove function of the shopping cart class would do the trick, but it didn't make any difference.
Is there a way to achieve this during checkout with OPC?