Jump to content

Gyakutsuki

♥Ambassador
  • Content count

    727
  • Joined

  • Last visited

  • Days Won

    15

Everything posted by Gyakutsuki

  1. It's possible to include to minify the code like HTMl, js, css. For example : create a class call MinifyCode.php in Classes directory (catalog) Class MinifyCode { // HTML Minifier function minifyHtml($input) { if (trim($input) === "") return $input; // Remove extra white-space(s) between HTML attribute(s) $input = preg_replace_callback('#<([^\/\s<>!]+)(?:\s+([^<>]*?)\s*|\s*)(\/?)>#s', function ($matches) { return '<' . $matches[1] . preg_replace('#([^\s=]+)(\=([\'"]?)(.*?)\3)?(\s+|$)#s', ' $1$2', $matches[2]) . $matches[3] . '>'; }, str_replace("\r", "", $input)); // Minify inline CSS declaration(s) if (strpos($input, ' style=') !== false) { $input = preg_replace_callback('#<([^<]+?)\s+style=([\'"])(.*?)\2(?=[\/\s>])#s', function ($matches) { return '<' . $matches[1] . ' style=' . $matches[2] . $this->minifyCss($matches[3]) . $matches[2]; }, $input); } return preg_replace( array( // t = text // o = tag open // c = tag close // Keep important white-space(s) after self-closing HTML tag(s) '#<(img|input)(>| .*?>)#s', // Remove a line break and two or more white-space(s) between tag(s) '#(<!--.*?-->)|(>)(?:\n*|\s{2,})(<)|^\s*|\s*$#s', '#(<!--.*?-->)|(?<!\>)\s+(<\/.*?>)|(<[^\/]*?>)\s+(?!\<)#s', // t+c || o+t '#(<!--.*?-->)|(<[^\/]*?>)\s+(<[^\/]*?>)|(<\/.*?>)\s+(<\/.*?>)#s', // o+o || c+c '#(<!--.*?-->)|(<\/.*?>)\s+(\s)(?!\<)|(?<!\>)\s+(\s)(<[^\/]*?\/?>)|(<[^\/]*?\/?>)\s+(\s)(?!\<)#s', // c+t || t+o || o+t -- separated by long white-space(s) '#(<!--.*?-->)|(<[^\/]*?>)\s+(<\/.*?>)#s', // empty tag '#<(img|input)(>| .*?>)<\/\1\x1A>#s', // reset previous fix '#( ) (?![<\s])#', // clean up ... // Force line-break with ` ` or ` ` '#&\#(?:10|xa);#', // Force white-space with ` ` or ` ` '#&\#(?:32|x20);#', // Remove HTML comment(s) except IE comment(s) '#\s*<!--(?!\[if\s).*?-->\s*|(?<!\>)\n+(?=\<[^!])#s' ), array( "<$1$2</$1\x1A>", '$1$2$3', '$1$2$3', '$1$2$3$4$5', '$1$2$3$4$5$6$7', '$1$2$3', '<$1$2', '$1 ', "\n", ' ', "" ), $input); } // CSS Minifier => http://ideone.com/Q5USEF + improvement(s) function minifyCss($input) { if (trim($input) === "") return $input; // Force white-space(s) in `calc()` if (strpos($input, 'calc(') !== false) { $input = preg_replace_callback('#(?<=[\s:])calc\(\s*(.*?)\s*\)#', function ($matches) { return 'calc(' . preg_replace('#\s+#', "\x1A", $matches[1]) . ')'; }, $input); } return preg_replace( array( // Remove comment(s) '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s', // Remove unused white-space(s) '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~+]|\s*+-(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}"\']++|"(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')*+{)|^\s++|\s++\z|(\s)\s+#si', // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0` '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si', // Replace `:0 0 0 0` with `:0` '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i', // Replace `background-position:0` with `background-position:0 0` '#(background-position):0(?=[;\}])#si', // Replace `0.6` with `.6`, but only when preceded by a white-space or `=`, `:`, `,`, `(`, `-` '#(?<=[\s=:,\(\-]|&\#32;)0+\.(\d+)#s', // Minify string value '#(\/\*(?>.*?\*\/))|(?<!content\:)([\'"])([a-z_][-\w]*?)\2(?=[\s\{\}\];,])#si', '#(\/\*(?>.*?\*\/))|(\burl\()([\'"])([^\s]+?)\3(\))#si', // Minify HEX color code '#(?<=[\s=:,\(]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i', // Replace `(border|outline):none` with `(border|outline):0` '#(?<=[\{;])(border|outline):none(?=[;\}\!])#', // Remove empty selector(s) '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s', '#\x1A#' ), array( '$1', '$1$2$3$4$5$6$7', '$1', ':0', '$1:0 0', '.$1', '$1$3', '$1$2$4$5', '$1$2$3', '$1:0', '$1$2', ' ' ), $input); } // JavaScript Minifier function minifyJs($input) { if (trim($input) === "") return $input; return preg_replace( array( // Remove comment(s) '#\s*("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\')\s*|\s*\/\*(?!\!|@[member='CC']_on)(?>[\s\S]*?\*\/)\s*|\s*(?<![\:\=])\/\/.*(?=[\n\r]|$)|^\s*|\s*$#', // Remove white-space(s) outside the string and regex '#("(?:[^"\\\]++|\\\.)*+"|\'(?:[^\'\\\\]++|\\\.)*+\'|\/\*(?>.*?\*\/)|\/(?!\/)[^\n\r]*?\/(?=[\s.,;]|[gimuy]|$))|\s*([!%&*\(\)\-=+\[\]\{\}|;:,.<>?\/])\s*#s', // Remove the last semicolon '#;+\}#', // Minify object attribute(s) except JSON attribute(s). From `{'foo':'bar'}` to `{foo:'bar'}` '#([\{,])([\'])(\d+|[a-z_]\w*)\2(?=\:)#i', // --ibid. From `foo['bar']` to `foo.bar` '#([\w\)\]])\[([\'"])([a-z_]\w*)\2\]#i', // Replace `true` with `!0` '#(?<=return |[=:,\(\[])true\b#', // Replace `false` with `!1` '#(?<=return |[=:,\(\[])false\b#', // Clean up ... '#\s*(\/\*|\*\/)\s*#' ), array( '$1', '$1$2', '}', '$1$3', '$1.$3', '!0', '!1', '$1' ), $input); } } In includes/classes/sosc_template.php Add at this end /* * Minify HTML code * * @[member='param'] string module name * @[member='Return'], return the minify code * @[member='access'] public */ function getMinifyTemplateBlockModule($template_module) { if (CONFIGURATION_MINIFY_TEMPLATE == 'true') { // activate or not the minifycode $minifyCode = new MinifyCode(); $str = $this->getBlocks($template_module); $minify = $minifyCode->minifyHtml($str); // minify the only the html code } else { $minify = $this->getBlocks($template_module); } return $minify; } function getMinifyTemplateBlockContent($template_module) { if (CONFIGURATION_MINIFY_TEMPLATE == 'true') { // activate or not the minifycode $minifyCode = new MinifyCode(); $str = $this->getBlocks($template_module); $minify = $minifyCode->minifyHtml($str); // minify the only the html code } else { $minify = $this->getBlocks($template_module); } return $minify; } } Database: INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) VALUES ('Do you want to minify the html code in the shop catalog', 'CONFIGURATION_MINIFY_TEMPLATE', 'false', 'Minify the HTML code to improve site speed' , '1', '5', 'osc_cfg_select_option(array(\'true\', \'false\'), ', now()); Now change inside the code these elements in all files. $oscTemplate->getContent('account') by by $oscTemplate->getMinifyTemplateBlockContent('account') $oscTemplate->getBlocks('account') by $oscTemplate->getMinifyTemplateBlockModule('account') Must work.
  2. @@Dan Cole Ok, depends on your configuration in order total and coupon (the setup is very important and you can have at the end some difference, yes it's a bug no simple to resolve) you can have a difference between the shopping and the checkout process This configuration for canada work for me : Sort order in module total order Coupon réduction 1 Expédition 10 Sous-Total 8 Taxes 20 Total 50 and in Coupon : the most important display discount with coupon : true calcul the discount after the taxe :false display taxe applied : false sort order : 1 and for shop configuration display price with taxe : no In my cart not connected Code coupon test applique: -10.00CAD Sous-Total: 25.00CAD Livraison gratuite (livraison offerte dés 20.): 0.00CAD Zone TVH 9.975: 2.49CAD Zone TPS 5%: 1.25CAD Total: 28.74CAD in my cart connected : Code coupon test applique: -10.00CAD Sous-Total: 25.00CAD Livraison gratuite (livraison offerte dés 20.): 0.00CAD Zone TVH 9.975: 2.49CAD Zone TPS 5%: 1.25CAD Total: 28.74CAD in checkout confirmation Code coupon test applique: -10.00CAD Sous-Total: 25.00CAD Livraison gratuite (livraison offerte dés 20.): 0.00CAD Zone TVH 9.975: 2.49CAD Zone TPS 5%: 1.25CAD Total: 28.74CAD
  3. no work with on not taxe. see my email
  4. the system work when your are login or not
  5. $zone_country_id must be $country_id
  6. try with this, it work for me $products = $OSCOM_ShoppingCart->get_products(); for ($i=0, $n=sizeof($products); $i<$n; $i++) { $products_tax = Tax::getTaxRate($products[$i]['tax_class_id'], $OSCOM_Order->delivery['country_id'], $OSCOM_Order->delivery['zone_id']); $products_tax_description = Tax::getTaxRateDescription($products[$i]['tax_class_id'], $OSCOM_Order->delivery['country_id'], $OSCOM_Order->delivery['zone_id']); if ( DISPLAY_PRICE_WITH_TAX == 'true' ) { //Modified by Strider 42 to correct the tax calculation when a customer is not logged in $tax_val = (($products[$i]['final_price']/100)*$products_tax)*$products[$i]['quantity']; } else { $tax_val = (($products[$i]['final_price']*$products_tax)/100)*$products[$i]['quantity']; } if ( !empty($OSCOM_Order->info['tax']) ) { $OSCOM_Order->info['tax'] += $tax_val; } else { $OSCOM_Order->info['tax'] = $tax_val; } if (!empty($OSCOM_Order->info['tax_groups']) ) { $OSCOM_Order->info['tax_groups']['' . $products_tax_description . ''] += $tax_val; } else { $OSCOM_Order->info['tax_groups']['' . $products_tax_description . ''] = $tax_val; }
  7. The add must be deleted, not interested in this case. The contribution had a bug to zone id and country id, I just changed theses elements.
  8. @@Dan Cole Ok work like a charm just a modification 1/ Remove in ot_discount.php this or insert comment // $OSCOM_Order->info['total'] = $OSCOM_Order->info['total'] - $discount; // $OSCOM_Order->info['subtotal'] -= $discount; // unset($_SESSION['coupon']); 2/ in classe coupon discount add this two functions becarefull on that : $_GET['shopping_cart'] or if ($PHP_SELF == 'shopping_cart') in shopping_cart.php $_SESSION['shopping_cart'] i don't exactly remember is the name else change private by public and in getZoneCountryid() write var_dump($_SESSION). /* * Display the id of the country zone id * @[member='param'] * @[member='Return'] $zone_country_id, id country zone id * @[member='access'] private */ private function getZoneCountryid() { if (isset($_GET['shopping_cart'])) { //$tax_address['entry_zone_id'] $zone_country_id = $_SESSION['cart_zone']; } else { $zone_country_id = $_SESSION['shopping_cart']['shipping_address']['zone_id']; } return $zone_country_id; } /* * Display the id of the country * @[member='param'] * @[member='Return'] $zone_country_id, id country * @[member='access'] private */ private function getCountryid() { if (isset($_GET['shopping_cart'])) { // $tax_address['entry_country_id'] $country_id = $_SESSION['cart_country_id']; } else { $zone_country_id = $_SESSION['shopping_cart']['shipping_address']['country_id']; } return $country_id; } In this function total_valid_products change this line (sorry don't remember exactlythe synthax, it's mine. $this->getCountryid() and $this->getZoneCountryid() doesn't have any information, that's why the element does'nt display. The bug is here for( $i = 0; $i < count( $products ); $i++ ) { if (DISPLAY_PRICE_WITH_TAX == 'true'){ $product_tax = Tax::getTaxRate($products[$i]['tax_class_id'], $this->getCountryid(), $this->getZoneCountryid()); .... If you want a professionnal code program like phpstorm, you will see yours errors. That's all, I can send you the classe but I rewrite all and the code is different than the 2.3 (reverse ingeniring must be done) but with this element you have the solution, I think.
  9. Ok Dan, I am rewriting the class, let me time to test and i will explain you to integrate the classif you are interesting because I want I resolve pb inside and also my pb. If it succes, I tell you.
  10. In quebec it's arround 14%, curently I try to resolve my clic system (3 to appear a taxe), after I will see the taxe. This example above is a way, not sur it's the best.
  11. I think to appear the taxe, you need to implement the code like for the $OSCOM_Order->info['total'] = $OSCOM_Order->info['total'] - $discount; The example above is an ideabut not sure. I am not in in this moment. try to test this quickly in ot_discount_coupon.php after $order->info['subtotal'] -= $discount; //take the similar code in your case sorry but I don't work on 2.3.x in the module order total. You must see the taxes and the total order $OSCOM_ShoppingCart= Registry::get('ShoppingCart'); $products = $OSCOM_ShoppingCart->get_products(); for ($i=0, $n=sizeof($products); $i<$n; $i++) { $products_tax = Tax::getTaxRate($products[$i]['tax_class_id'], $OSCOM_Order->delivery['country_id'], $OSCOM_Order->delivery['zone_id']); var_dump($products_tax); $OSCOM_Order->info['total'] += $products_tax; var_dump($OSCOM_Order->info['total'] ); }
  12. the code included in order total calcul (module) $products = $OSCOM_ShoppingCart->get_products(); for ($i=0, $n=sizeof($products); $i<$n; $i++) { $products_tax = Tax::getTaxRate($products[$i]['tax_class_id'], $OSCOM_Order->delivery['country_id'], $OSCOM_Order->delivery['zone_id']); $products_tax_description = Tax::getTaxRateDescription($products[$i]['tax_class_id'], $OSCOM_Order->delivery['country_id'], $OSCOM_Order->delivery['zone_id']); if ( DISPLAY_PRICE_WITH_TAX == 'true' ) { //Modified by Strider 42 to correct the tax calculation when a customer is not logged in $tax_val = (($products[$i]['final_price']/100)*$products_tax)*$products[$i]['quantity']; } else { $tax_val = (($products[$i]['final_price']*$products_tax)/100)*$products[$i]['quantity']; } if ( !empty($OSCOM_Order->info['tax']) ) { $OSCOM_Order->info['tax'] += $tax_val; } else { $OSCOM_Order->info['tax'] = $tax_val; } if (!empty($OSCOM_Order->info['tax_groups']) ) { $OSCOM_Order->info['tax_groups']['' . $products_tax_description . ''] += $tax_val; } else { $OSCOM_Order->info['tax_groups']['' . $products_tax_description . ''] = $tax_val; } // Modified by Strider 42 to correct the order total figure when shop displays prices with tax if ( DISPLAY_PRICE_WITH_TAX == 'true' ) { $OSCOM_Order->info['total']; } else { $OSCOM_Order->info['total'] += $tax_val; }
  13. look the order_total in the module shopping cart, you have the first way.
  14. @@Dan Cole How many clic do you need to see the result. For me it's weird : 3 clics to see the discount (good coupon) 2 clics after to delete the discount (bas coupon)
  15. yes it's another solution and better idea
  16. I also have a problem with the taxes, it diseapear ! Step by step This element does'nt allow in checkout_confirmation to use this code (below) This code go in ot_discount_coupon.php $PHP_SEL = $PHP_SELF $this->output[] = array('title' => $OSCOM_Order->coupon->format_display($tax_group) . ':', 'text' => $text, 'value' => $display_type . $discount ); if (MODULE_SHOPPING_CART_COUPON_DISCOUNT_STATUS == 'true' && $PHP_SELF == 'shopping_cart.php') { $OSCOM_Order->info['total'] = $OSCOM_Order->info['total'] - $discount; $OSCOM_Order->info['subtotal'] -= $discount; }
  17. I don't text with canada tax, tomorrow but work with normal tax. include this adapted at your case if (MODULE_SHOPPING_CART_COUPON_DISCOUNT_CONTENT_WIDTH == 'true'&& $PHP_SEL="shopping_cart.php) { $OSCOM_Order->info['total'] = $OSCOM_Order->info['total'] - $discount; $OSCOM_Order->info['subtotal'] -= $discount; }
  18. Seem to work in different configuration with the module. No work with me if I insertt a limited price (pb), limit coupon (normal), number available, categories, products, manufacturers error on coupon name Could you test on your part Tk
  19. @Dan Cole A first way, but not tested in deep with all options after this in ot_discount.php $this->output[] = array('title' => $OSCOM_Order->coupon->format_display($tax_group) . ':', 'text' => $text, 'value' => $display_type . $discount ); add $OSCOM_Order->info['total'] = $OSCOM_Order->info['total'] - $discount; $OSCOM_Order->info['subtotal'] -= $discount; in other case, it's possible to add also for conflict problem with checkout_confirmation.php if (MODULE_SHOPPING_CART_COUPON_DISCOUNT_CONTENT_WIDTH == 'true'&& $PHP_SEL="shopping_cart.php) { $OSCOM_Order->info['total'] = $OSCOM_Order->info['total'] - $discount; $OSCOM_Order->info['subtotal'] -= $discount; } Let me know if it's first idea works;
  20. Do you tried with different configuration taxe, no tax, above sub total, after sub total, after total ?
  21. @Dan Cole no inside coupon discount
  22. try to insert unset($_SESSION['coupon']); just a litlle improve if it can help you (HTML::sanitize change by good osc 2.3.x synthax) //verifier intégrité coupon if (!isset($_SESSION['coupon'])) { $_SESSION['coupon'] = HTML::sanitize($_POST['coupon']); } //this needs to be set before the order object is created, but we must process it after if (isset($_SESSION['coupon'])) { if (osc_not_null($_SESSION['coupon'])) { $_SESSION['coupon'] = HTML::sanitize($_SESSION['coupon']); } else { unset($_SESSION['coupon']); } } else { unset($_SESSION['coupon']); }
  23. @Dan Cole is it possible to display your work ? I'm developping something but not yet finish. Good news I am able to display the discount amount without customer session Bad news : the total amount is not calculate. Below an example on the code in execute function. if (isset($_POST['coupon'])) { //verifier intégrité coupon if (!isset($_SESSION['coupon'])) { $_SESSION['coupon'] = HTML::sanitize($_POST['coupon']); } //this needs to be set before the order object is created, but we must process it after //this needs to be set before the order object is created, but we must process it after // $coupon = osc_db_prepare_input($_POST['coupon']); if (isset($_SESSION['coupon'])) { $coupon = ''; if (tep_not_null($_SESSION['coupon'])) { $_SESSION['coupon'] = tep_db_prepare_input($_SESSION['coupon']); } } require_once(DIR_WS_CLASSES . 'order.php'); $order = new order; // discount coupons if (isset( $_SESSION['coupon']) && is_object($order->coupon) ) { $order->coupon->verify_code(); // erreur quand le nbr de coupon permis = 0 et debug = false } $form = tep_draw_form('coupon', osc_href_link('sopping_cart.php', '', 'SSL'), 'post', 'id ="coupon"onsubmit="return check_form();"', true); $endform = '</form>'; $coupon = tep_draw_input_field('coupon', '', 'id="inputCoupon" class="input-sm" placeholder="' . ENTRY_DISCOUNT_COUPON . '"' );; $button_coupon = tep_draw_button(IMAGE_BUTTON_CONTINUE, null, null, 'secondary', null, 'sm'); if (MODULE_ORDER_TOTAL_DISCOUNT_COUPON_STATUS == 'true') { // call template with $form . $coupon . $button_coupon . $endform } } }
  24. @Dan Cole No, I tried but it doesn't work, no search more.
×