Jump to content

kishanunjia

Members
  • Posts

    2
  • Joined

  • Last visited

About kishanunjia

  • Birthday 06/24/1990

Profile Information

  • First Name
    kishan
  • Last Name
    unjia

Recent Profile Visitors

56 profile views

kishanunjia's Achievements

Newbie

Newbie (1/14)

  • Week One Done Rare
  • One Month Later Rare
  • One Year In Rare

Recent Badges

0

Reputation

  1. Just create a controller with the name you want for the page, and put it in /overrides/controllers/front/. The name of the controller must be NameyouwantforthepageController.php Here is a basic class that will work: class MyPageController extends FrontController { /** * Initialize controller * @see FrontController::init() */ public function init() { parent::init(); } /** * Assign template vars related to page content * @see FrontController::initContent() */ public function initContent() { parent::initContent(); $this->setTemplate(_PS_THEME_DIR_.'my-page.tpl'); } } Take a look at the FrontController to see what method you need to override to add functionnalities, for example setMedia() to add CSS / JS files. You will then be able to add a pretty url in the back office in the SEO panel.
  2. /override/class/Cart.php using $cart->getProducts() to get all products from shopping cart and find out the tax rate for each product and group them together. Add in Cart.php $products = $this->getProducts(); $virtual_context = Context::getContext()->cloneContext(); $address_factory = Adapter_ServiceLocator::get('Adapter_AddressFactory'); $price_calculator = Adapter_ServiceLocator::get('Adapter_ProductPriceCalculator'); $configuration = Adapter_ServiceLocator::get('Core_Business_ConfigurationInterface'); $ps_tax_address_type = $configuration->get('PS_TAX_ADDRESS_TYPE'); $ps_use_ecotax = $configuration->get('PS_USE_ECOTAX'); $ps_round_type = $configuration->get('PS_ROUND_TYPE'); $ps_ecotax_tax_rules_group_id = $configuration->get('PS_ECOTAX_TAX_RULES_GROUP_ID'); $compute_precision = $configuration->get('_PS_PRICE_COMPUTE_PRECISION_'); $gc_tax_calculation=array(); if(!empty($products)) { $i=1; foreach ($products as $product) { if ($virtual_context->shop->id != $product['id_shop']) { $virtual_context->shop = new Shop((int)$product['id_shop']); } $ps_tax_address_type = $configuration->get('PS_TAX_ADDRESS_TYPE'); if ($ps_tax_address_type == 'id_address_invoice') { $id_address = (int)$this->id_address_invoice; } else { $id_address = (int)$product['id_address_delivery']; } if (!$address_factory->addressExists($id_address)) { $id_address = null; } $null = null; $org_tax_price = $price_calculator->getProductPrice( (int)$product['id_product'], false, (int)$product['id_product_attribute'], 6, null, false, true, $product['cart_quantity'], false, (int)$this->id_customer ? (int)$this->id_customer : null, (int)$this->id, $id_address, $null, $ps_use_ecotax, true, $virtual_context ); $address = $address_factory->findOrCreate($id_address, true); $id_tax_rules_group = Product::getIdTaxRulesGroupByIdProduct((int)$product['id_product'], $virtual_context); $tax_calculator = TaxManagerFactory::getManager($address, $id_tax_rules_group)->getTaxCalculator(); if(!empty($id_tax_rules_group)) { $tax_rules_name_get='SELECT * FROM `'._DB_PREFIX_.'tax_rules_group` WHERE id_tax_rules_group = '.$id_tax_rules_group; $tax_rules_name_get_execute=Db::getInstance()->ExecuteS($tax_rules_name_get); if(!empty($tax_rules_name_get_execute)) { $rule_name=$tax_rules_name_get_execute[0]['name']; } $ff_nal=$tax_calculator->addTaxes($org_tax_price); switch ($ps_round_type) { case Order::ROUND_TOTAL: $org_tax_price = $org_tax_price * (int)$product['cart_quantity']; $ff_nal = $ff_nal * (int)$product['cart_quantity']; break; case Order::ROUND_LINE: $org_tax_price = Tools::ps_round($org_tax_price * $product['cart_quantity'], $compute_precision); $ff_nal = Tools::ps_round($ff_nal * $product['cart_quantity'], $compute_precision); break; case Order::ROUND_ITEM: default: $org_tax_price = Tools::ps_round($org_tax_price, $compute_precision) * (int)$product['cart_quantity']; $ff_nal = Tools::ps_round($ff_nal, $compute_precision) * (int)$product['cart_quantity']; break; } if($org_tax_price != $ff_nal) { $product_tax = $ff_nal - $org_tax_price; $gc_tax_calculation['tax'.$product['id_product'].'_'.$i]=array('rule'=>$rule_name,'tax'=>$product_tax, 'id_product'=>$product['id_product'],'grp_id'=>$id_tax_rules_group); } } $i++; } } $final_tax_logic=array(); if(!empty($gc_tax_calculation)) { foreach($gc_tax_calculation as $tax_val) { $grp_id=$tax_val['grp_id']; $rule=$tax_val['rule']; $tax=$tax_val['tax']; $id_product=$tax_val['id_product']; if(!isset($final_tax_logic['grp_'.$grp_id])) { $final_tax_logic['grp_'.$grp_id]=array('rule'=>$rule,'tax'=>$tax,'id_product'=>$id_product,'grp_id'=>$grp_id); } else { $old_tax=$final_tax_logic['grp_'.$grp_id]['tax']; $new_tax=$old_tax + $tax; $final_tax_logic['grp_'.$grp_id]['tax'] = $new_tax; } } } Assign the calculated result to Smarty variable $summary = array( 'gc_tax_calculation' => $final_tax_logic, ); Get calculated result to Smarty variable in shopping-cart.tpl {if isset($gc_tax_calculation) && $gc_tax_calculation} {foreach from=$gc_tax_calculation item=tax_calculation} <tr class="cart_tax_calculation grp_{$tax_calculation['grp_id']}" id="grp_{$tax_calculation['grp_id']}"> <td colspan="{$col_span_subtotal}" class="text-right">{$tax_calculation['rule']}</td> <td colspan="2" class="price">{displayPrice price=$tax_calculation['tax']}</td> </tr> {/foreach} {/if} have fun
×
×
  • Create New...