Author Topic: Category Shipping Help  (Read 1987 times)

DanBH

  • Beginner
  • *
  • Posts: 36
Category Shipping Help
« on: April 07, 2015, 16:43:31 pm »
Coming into a job with a Joomla site that uses Virtuemart 1.1.9

They seem to have added code into the basket.php for virtuemart so that depending on the product category in the basket, the delivery amount changes.
I can change the amount and add new categories, however they can only be top level categories it seems.

I have basically no knowledge of PHP.
What I would need is a way to target a sub-catagory rather than only top level ones.

Code: [Select]
// Added for the zone shipping module
$vars["zone_qty"] = 0;
$weight_total = 0;
$weight_subtotal = 0;
$tax_total = 0;
$shipping_total = 0;
$shipping_tax = 0;
$order_total = 0;
$discount_before=$discount_after=$show_tax=$shipping=false;
$product_rows = Array();
$is_flooring = $is_junckers = $is_accessories = $is_quickstep = false;
$db = new ps_DB;
$_SESSION['cart']['osw'] = 0;
$ids = array();
for ($i=0;$i<$cart["idx"];$i++) {
  $ids[] = $cart[$i]['product_id'];
  $q = "SELECT category_parent_id FROM #__vm_category_xref WHERE category_child_id = ".$cart[$i]['category_id'];
      $db->setQuery( $q );
      $db->query();
      $parent = $parentx = $db->loadResult();
      if ($parent == 0) {
        $parent = $parentx = $cart[$i]['category_id'];
      }
      while ($parent > 0 && $parent != 45) {
        $parentx = $parent;
        $q = "SELECT category_parent_id FROM #__vm_category_xref WHERE category_child_id = $parent";
+ Attachments and other options
Verification:
+ Attachments and other options
        $db->setQuery( $q );
        $db->query();
        $parent = $db->loadResult();
      }
      if ($parentx == 45) $is_junckers = true;
      elseif (in_array($parentx, array(2, 17, 18, 19))) $is_flooring = true;
  elseif ($parentx == 319) $is_quickstep = true;
      else $is_accessories = true;

Above is the code that I believe will need editing.
Bellow was the line I have added. The category number is 319 but it doesn't seem to work.
Code: [Select]
  elseif ($parentx == 319) $is_quickstep = true;

Is it that $parentx is only looking at the top level categories?

I have no idea if I need to edit or add code elsewhere so any questions you have throw my way.