Back to PhocacartShipping class

Method storeShippingMethods

public static
storeShippingMethods
(mixed $shippingsArray, mixed $id, mixed $table = 'payment')

Method storeShippingMethods - Source code

/* used as payment rule*/
public static function storeShippingMethods($shippingsArray, $id, $table = 'payment')
{
    if ($table == 'payment') {
        $t = '#__phocacart_payment_method_shipping';
        $c = 'payment_id';
    }
    if ((int) $id > 0) {
        $db = Factory::getDBO();
        $query = ' DELETE ' . ' FROM ' . $t . ' WHERE ' . $c . ' = ' . (int) $id;
        $db->setQuery($query);
        $db->execute();
        if (!empty($shippingsArray)) {
            $values = array();
            $valuesString = '';
            foreach ($shippingsArray as $k => $v) {
                $values[] = ' (' . (int) $id . ', ' . (int) $v[0] . ')';
            }
            if (!empty($values)) {
                $valuesString = implode(',', $values);
                $query = ' INSERT INTO ' . $t . ' (' . $c . ', shipping_id)' . ' VALUES ' . (string) $valuesString;
                $db->setQuery($query);
                $db->execute();
            }
        }
    }
}