Jump to content



wHiTeHaT

Member Since 01 Nov 2002
ONLINE Last Active Today, 09:48
*****

#1754438 Converting options and images addon to BS

Posted by wHiTeHaT on 09 March 2017 - 12:57

echo '<div class="col-xs-2">';

should be then :

<!-- just example col-md-12 is NOT need, is only to show how you can extend views -->
echo '<div class="col-xs-6 col-sm-2 col-md-12">';



#1752975 Sessions, languages and ajax loading

Posted by wHiTeHaT on 02 February 2017 - 11:11

Thanks @Jack_mcs my problem are not rewriting the divs, it already does. I do it with jquery instead of pure ajax but the result is the same.
 
The thing that intrigues me is why the session is kept but not the language when you load the file ie:
 
if I access directly the file (not from the shopping cart file but directly) I've put a variable output on it. In that output I see the shopping cart is full, the user is logged... but the language is always the default one, not the chosen one.

you need to include the corresponding(required) language file in your cart_update.php, in this case your shopping_cart.php language file
 

  require('includes/languages/' . $language . '/shopping_cart.php');

you can also try

  require('includes/languages/' . $_SESSION['language'] . '/shopping_cart.php');

I disagree with jack when he say : That's not how it should be done.
There is no rule for that, and i prefer myself jQuery's $.post() method.
 
Below i will post a file with various "actions" when press an ajax button that do shopping cart actions globally over the whole store (so not just the shopping_cart.php)..
just use it as a reference ;)

<?php
if( isset( $_SERVER['HTTP_X_REQUESTED_WITH'] ) && ( $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' ) )
{
require('includes/application_top.php');
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_SHOPPING_CART);

   $messageStack->reset();
if(isset($_POST['products_id'])) {
    $products_id = $_POST['products_id'];
}
    switch ($_POST['action']) {
      // customer wants to update the product quantity in their shopping cart
      case 'update_product' : for ($i=0, $n=sizeof($_POST['products_id']); $i<$n; $i++) {
                                if (in_array($_POST['products_id'][$i], (is_array($_POST['cart_delete']) ? $_POST['cart_delete'] : array()))) {
                                  $cart->remove($_POST['products_id'][$i]);
                                  $messageStack->add('product_action', sprintf(PRODUCT_REMOVED, tep_get_products_name($_POST['products_id'][$i])), 'warning');
                                } else {
                                  $attributes = ($_POST['id'][$_POST['products_id'][$i]]) ? $_POST['id'][$_POST['products_id'][$i]] : '';
                                  $cart->add_cart($_POST['products_id'][$i], $_POST['cart_quantity'][$i], $attributes, false);
                                }
                              }
                             // tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
                              break;
      // customer removes a product from their shopping cart
      case 'remove_product' : if (isset($_POST['products_id'])) {
                                $cart->remove($_POST['products_id']);
                                $messageStack->add('product_action', sprintf(PRODUCT_REMOVED, tep_get_products_name($_POST['products_id'])), 'warning');
                              }
                              //tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
                              break;
// performed by the 'buy now' button in product listings and review page
   case 'add_buy_now_product' : 
   	if(isset($_POST['products_id'])) {

 if (tep_has_product_attributes($_POST['products_id'])) {
	$product_has_attributes = 'product_has_attributes';
 } else {
 if($_POST['buy_now_quantity']== "") {
 $quantity = 1;
 }else{
 $quantity = $_POST['buy_now_quantity']; 
}
     $cart->add_cart($_POST['products_id'], $cart->get_quantity($_POST['products_id'])+$quantity);
	 
     $messageStack->add('product_action', sprintf(PRODUCT_ADDED, tep_get_products_name((int)$products_id)), 'info');
    
	// We generate the messageStack //
    $ajaxMessageStack  = $messageStack->output('product_action');
	
	}
}	
   break;	
	
	
	
	// performed by the 'buy now' button in product listings and review page
	case 'buy_now':	

	
    if (tep_has_product_attributes($products_id)) {
 	
	/* we have attributes , we use this marker to re-direct to the actual product_info.php product, this is done by the jQuery function */
	$product_has_attributes = 'product_has_attributes';
	
	}else {
    $cart->add_cart($products_id, $cart->get_quantity($products_id)+1);
    $messageStack->add('product_action', sprintf(PRODUCT_ADDED, tep_get_products_name((int)$products_id)), 'info');
    
	/* We generate the messageStack */
    $ajaxMessageStack  = $messageStack->output('product_action');
	
	}
	break;
      // customer removes a product from their shopping cart
      case 'add_wishlist' :
	if(isset($_POST['products_id'])) {
		if(isset($_POST['id'])) {
			$attributes_id = $_POST['id'];
			tep_session_register('attributes_id');
		}
		$wishlist_id = $_POST['products_id'];
		tep_session_register('wishlist_id');
	}
	  if(tep_session_is_registered('wishlist_id')) {
  	$wishList->add_wishlist($wishlist_id, $attributes_id);
	    $product_id = $wishlist_id;
   	tep_session_unregister('wishlist_id');
  	if(tep_session_is_registered('attributes_id')) tep_session_unregister('attributes_id');
  	if(WISHLIST_REDIRECT == 'Yes') {
	  	tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $product_id));
	  }
  }
	    $messageStack->add('wishlist_action', sprintf(WISHLIST_ADDED, tep_get_products_name((int)$_POST['products_id'])), 'info');
	/* We generate the messageStack */
    $ajaxMessageStack  = $messageStack->output('wishlist_action');
                              break;	
	case 'add_product':	
	if(isset($_POST['products_id']) && is_numeric($_POST['products_id'])) {
    $attributes = isset($_POST['id']) ? $_POST['id'] : '';
    $cart->add_cart($_POST['products_id'], $cart->get_quantity(tep_get_uprid($_POST['products_id'], $attributes)) + $_POST['cart_quantity'], $attributes);	
    $messageStack->add('product_action', sprintf(PRODUCT_ADDED, tep_get_products_name((int)$_POST['products_id'])), 'info');
	
	/* We generate the messageStack */
    $ajaxMessageStack  = $messageStack->output('product_action');
	
	}
	break;
	}
							  
							  

    /* we replace the action for closing the alert message, instead we give it the action to close the dialog */
    $ajaxModalContent  = str_replace("data-dismiss=\"alert\"","data-dismiss=\"modal\"", $ajaxMessageStack);

if ($_POST['action'] == 'add_wishlist') {
    
	   /* we compile global reference data into the 'free_will' array for the json array */	  
		$compiled_products['free_will'] = array(
									 'ajaxModalContent'=> $ajaxModalContent
									 );	
     /* we need to set headers to tell we have no standard content */		
      header('Content-Type: application/json');										 
echo json_encode($compiled_products);									 
	
}else{	
	/* we set the starting marker point always to 0, as we check for it each time we do any cart actions */
    $any_out_of_stock = 0;
	
	/* we call this nifty class function to retrieve all products that where inserted to the cart */
	/* NOTICE: the default oscommerce function does not calculate prices based on customer settings like currency&taxes, we need to do this ourself */
    $products = $cart->get_products();
	
	/* we itterate over the generated array of products that the function above provided us with */
    for ($i=0, $n=sizeof($products); $i<$n; $i++) {
	   
	   /* self explaining */
	   if (STOCK_CHECK == 'true') {
       
	   /* the actual function what does the stock check */
	   $stock_check = tep_check_stock($products[$i]['id'], $products[$i]['quantity']);
       
	   /* if the callback to the above function is not null */
	   if (tep_not_null($stock_check)) {
       
	   /* we got a marker, we go use it later */
	   $any_out_of_stock = 1;
       
	   /* the stock check found a product that has a negative stock corresponding to the client's required quantity */
       $products_name = $products[$i]['name'] . $stock_check;
        }else{
	   
	   /* stock check IS enabled, but we still need the name...Bahh!! */
	   $products_name = $products[$i]['name'];
	   }
      
	  }else{
	  
	  /* stock check is NOT enabled so lets get the name  ....finaly!! */
	  $products_name = $products[$i]['name'];
	   }
	   
	   /* So let's build, we compile only the required data for reference */
	  $compiled_products[] = array('product_id' => $products[$i]['id'],
	                               'product_price' => $currencies->display_price($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']),
								   'product_name' => $products_name);
	  
	  }
	  
	  /* if we found above a product out of stock , we need to generate a message */
      
	  /* we go use our marker from above */
	  if ($any_out_of_stock == 1) {
      
	  /* self explaining */
	  if (STOCK_ALLOW_CHECKOUT == 'true') {
      
	  /* We got the message that there are products out of stock, however we are allowed to checkout */
	  $stock_alert = '<div class="alert alert-warning">' . OUT_OF_STOCK_CAN_CHECKOUT . '</div>';

      } else {
	  
	  /* We got the message that there are products out of stock, here we are NOT allowed to checkout */
      $stock_alert = '<div class="alert alert-danger">' . OUT_OF_STOCK_CANT_CHECKOUT . '</div>';
       }
      }
       if (strpos($product_has_attributes,'product_has_attributes') !== false) {
	   $product_has_attributes = $product_has_attributes;
	   }
	   /* we compile global reference data into the 'free_will' array for the json array */	  
		$compiled_products['free_will'] = array('total' => SUB_TITLE_SUB_TOTAL . ' ' . $currencies->format($cart->show_total()), 
		                             'headcounter' => sprintf(HEADER_CART_CONTENTS, $cart->count_contents()),
									 'subheadcounter' => sprintf(HEADER_CART_HAS_CONTENTS, $cart->count_contents(), $currencies->format($cart->show_total())),
									 'stock_alert' => $stock_alert,
									 'product_has_attributes' => $product_has_attributes,
									 'ajaxModalContent'=> $ajaxModalContent
									 );

      /* if we ever need it we can get a full list of what is inside the cart, keep in mind currencie&taxes are not calculated */
        //$compiled_products['allproducts'] = $products;

     /* we need to set headers to tell we have no standard content */		
      header('Content-Type: application/json');							  

     /* we actual need to check if we have something in the cart ...sigh!!! */
      if ($cart->count_contents() > 0) {

     /*now let us send all the data back to the jQuery function */	
     echo json_encode($compiled_products);
		
    }else{

    /* we have an empty cart.... what i do here!!! */		
    echo '0';		
    
	}
}		
require('includes/application_bottom.php');
}else{
require('includes/application_top.php');
require(DIR_WS_INCLUDES . 'template_top.php');
require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_PRODUCT_INFO);
?>
<div class="contentContainer">
  <div class="contentText">
    <div class="alert alert-warning"><?php echo TEXT_PRODUCT_NOT_FOUND; ?></div>
  </div>

  <div class="pull-right">
    <?php echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'glyphicon-chevron-right', tep_href_link(FILENAME_DEFAULT)); ?>
  </div>
</div>
<?php
require(DIR_WS_INCLUDES . 'template_bottom.php');
require(DIR_WS_INCLUDES . 'application_bottom.php');
}
?>

Corresponding ht module (just use it as reference):

<?php
/*
  $Id$

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2014 osCommerce

  Released under the GNU General Public License
*/

  class ht_ajax_cart {
    var $code = 'ht_ajax_cart';
    var $group = 'footer_scripts';
    var $title;
    var $description;
    var $sort_order;
    var $enabled = false;

    function ht_ajax_cart() {
      $this->title = MODULE_FOOTER_SCRIPT_AJAXCART_TITLE;
      $this->description = MODULE_FOOTER_SCRIPT_AJAXCART_DESCRIPTION;

      if ( defined('MODULE_FOOTER_SCRIPT_AJAXCART_STATUS') ) {
        $this->sort_order = MODULE_FOOTER_SCRIPT_AJAXCART_SORT_ORDER;
        $this->enabled = (MODULE_FOOTER_SCRIPT_AJAXCART_STATUS == 'True');
      }
    }

    function execute() {
      global $oscTemplate;
	  	$oscTemplate->addBlock('<script>var myvalue; $(".add-product").on("click",function(e){$(".add-product").addClass("ajax-button"); myvalue = "add_product";  })</script>', $this->group);
	  	$oscTemplate->addBlock('<script> $(".wish-list").on("click",function(e){$(".wish-list").addClass("ajax-button"); myvalue = "add_wishlist";  })</script>', $this->group);
	  	$oscTemplate->addBlock('<script> $(".buy_now_qty_product").on("click",function(e){$(".buy_now_qty_product").addClass("ajax-button"); myvalue = "add_buy_now_product";  })</script>', $this->group);

    //$oscTemplate->addBlock('<script>$("form[name=\"shopping_cart_quantity\"]").submit(function(e){var t=$(e.target).attr("action");var n=$(this).serializeArray();n.push({name:"action",value:"update_product"});$.post("ajax_shop_cart.php",n,"json").done(function(e){console.log(e);$("tr.productsincart").removeClass("showme");if(e===0){$("#cart_in_head").html("<li id=\"cart_in_head\" class=\"nav navbar-text\">"+headerTextNoContent+"</li>");$("#checkout_head").remove();$(".ajax_response").remove();$(".contentText").html(""+cartTextEmpty+"<p class=\"text-right\">"+buttonContinueDefault+"</p>")}else{$.when($.each(e,function(e,t){$("tr").closest("[data-product-row=\'"+t.product_id+"\']").addClass("showme");$("strong").closest("[data-id-name=\'"+t.product_id+"\']").html(t.product_name);$("strong").closest("[data-pid=\'"+t.product_id+"\']").html(t.product_price)})).done(function(){$("tr.productsincart").not(".showme").remove();$("#cart_in_head a.dropdown-toggle").html(e["free_will"].headcounter);$("li.ajax_counter a").html(e["free_will"].subheadcounter);$("#ajax_price_total").html(e["free_will"].total).fadeOut(400).fadeIn(600);$("div.stock_control").html(e["free_will"].stock_alert).fadeOut(1e3).fadeIn(600).fadeOut(1e3).fadeIn(600)})}});return false})</script>', $this->group);
	$oscTemplate->addBlock('<script>function buildUpCartModal(){$("#bodyWrapper").prepend("<div class=\"modal fade\" id=\"myModal\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"myModalLabel\" aria-hidden=\"true\"><div class=\"modal-dialog\"><div class=\"modal-content\"><div class=\"modal-body\"></div><div class=\"modal-footer\"><button type=\"button\" class=\"btn btn-default\" data-dismiss=\"modal\">"+buttonContinue+"</button><a href=\""+cartLink+"\" class=\"btn btn-primary\" role=\"button\"><span class=\"glyphicon glyphicon-shopping-cart\"></span>" +headerViewCart+"</a></div></div></div></div>");$("#myModal").modal("show")}</script>', $this->group);
	$oscTemplate->addBlock('<script>function buildUpWishListModal(){$("#bodyWrapper").prepend("<div class=\"modal fade\" id=\"myModal\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"myModalLabel\" aria-hidden=\"true\"><div class=\"modal-dialog\"><div class=\"modal-content\"><div class=\"modal-body\"></div><div class=\"modal-footer\"><button type=\"button\" class=\"btn btn-default\" data-dismiss=\"modal\">"+buttonContinue+"</button><a href=\""+wishListLink+"\" class=\"btn btn-warning\" role=\"button\"><span class=\"glyphicon glyphicon-heart\"></span>"  +ViewWishList+"</a></div></div></div></div>");$("#myModal").modal("show")}</script>', $this->group);
		$oscTemplate->addBlock('<script>$("form[name=\"form_buy_now_product\"]").submit(function(e){$(".ajax-button").button(""); if(myvalue === "add_buy_now_product") {buildUpCartModal();} if(myvalue === "add_wishlist") {buildUpWishListModal();}var t=$(this).serializeArray();t.push({name:"action",value:myvalue});$.post("ajax_shop_cart.php",t,"json").done(function(e){ if(myvalue === "add_buy_now_product") {$("#cart_in_head").removeClass("nav navbar-text").addClass("dropdown");$("#cart_in_head").html("<a class=\"dropdown-toggle\" data-toggle=\"dropdown\" href=\"#\">"+e["free_will"].headcounter+"</a><ul class=\"dropdown-menu\"><li class=\"ajax_counter\"><a href=\""+cartLink+"\">"+e["free_will"].subheadcounter+"</a></li><li class=\"divider\"></li><li><a href=\""+cartLink+"\">"+headerViewCart+"</a></li><li class=\"divider\"></li><li id=\"checkout_head\"><a href=\""+checkOutShippingSll+"\">"+headerTextCheckout+"</a></li></ul>");} $(".modal-body").html(e["free_will"].ajaxModalContent)});return false})</script>', $this->group);

	$oscTemplate->addBlock('<script>$("form[name=\"cart_quantity\"]").submit(function(e){$(".ajax-button").button(""); if(myvalue === "add_product") {buildUpCartModal();} if(myvalue === "add_wishlist") {buildUpWishListModal();}var t=$(this).serializeArray();t.push({name:"action",value:myvalue});$.post("ajax_shop_cart.php",t,"json").done(function(e){ if(myvalue === "add_product") {$("#cart_in_head").removeClass("nav navbar-text").addClass("dropdown");$("#cart_in_head").html("<a class=\"dropdown-toggle\" data-toggle=\"dropdown\" href=\"#\">"+e["free_will"].headcounter+"</a><ul class=\"dropdown-menu\"><li class=\"ajax_counter\"><a href=\""+cartLink+"\">"+e["free_will"].subheadcounter+"</a></li><li class=\"divider\"></li><li><a href=\""+cartLink+"\">"+headerViewCart+"</a></li><li class=\"divider\"></li><li id=\"checkout_head\"><a href=\""+checkOutShippingSll+"\">"+headerTextCheckout+"</a></li></ul>");} $(".modal-body").html(e["free_will"].ajaxModalContent)});return false})</script>', $this->group);
	$oscTemplate->addBlock('<script>$("a.buy_now").on("click",function(e){var t=$(e.target).data("id-product");$(e.target).addClass("ajax-button");$(e.target).attr("data-loading-text","Processing");$(".ajax-button").button("");$.post("ajax_shop_cart.php",{products_id:t,action:"buy_now"},"json").done(function(e){if(e["free_will"].product_has_attributes=="product_has_attributes"){window.location.href="product_info.php?products_id="+t}else{buildUpCartModal();$("#cart_in_head").removeClass("nav navbar-text").addClass("dropdown");$("#cart_in_head").html("<a class=\"dropdown-toggle\" data-toggle=\"dropdown\" href=\"#\">"+e["free_will"].headcounter+"</a><ul class=\"dropdown-menu\"><li class=\"ajax_counter\"><a href=\""+cartLink+"\">"+e["free_will"].subheadcounter+"</a></li><li class=\"divider\"></li><li><a href=\""+cartLink+"\">"+headerViewCart+"</a></li><li class=\"divider\"></li><li id=\"checkout_head\"><a href=\""+checkOutShippingSll+"\">"+headerTextCheckout+"</a></li></ul>");$(".modal-body").html(e["free_will"].ajaxModalContent)}});return false})</script>', $this->group);

    //$oscTemplate->addBlock('<script>$(".remove_product").on("click",function(){var e=$(this).data("id-product");$.post("ajax_shop_cart.php",{products_id:e,action:"remove_product"},"json").done(function(e){console.log(e);$("tr.productsincart").removeClass("showme");if(e===0){$("#cart_in_head").html("<li id=\"cart_in_head\" class=\"nav navbar-text\">"+headerTextNoContent+"</li>");$("#checkout_head").remove();$(".ajax_response").remove();$(".contentText").html(""+cartTextEmpty+"<p class=\"text-right\">"+buttonContinueDefault+"</p>")}else{$.when($.each(e,function(e,t){$("tr").closest("[data-product-row=\'"+t.product_id+"\']").addClass("showme");$("strong").closest("[data-pid=\'"+t.product_id+"\']").html(t.product_price);$("#ajax_price_total").html(t.total).fadeOut(400).fadeIn(600)})).done(function(){$("tr.productsincart").not(".showme").remove();$("#cart_in_head a.dropdown-toggle").html(e["free_will"].headcounter);$("li.ajax_counter a").html(e["free_will"].subheadcounter);$("#ajax_price_total").html(e["free_will"].total).fadeOut(400).fadeIn(600);$("div.stock_control").html(e["free_will"].stock_alert).fadeOut(1e3).fadeIn(600).fadeOut(1e3).fadeIn(600)})}});return false})</script>', $this->group);
    $oscTemplate->addBlock('<script>$("body").on("hidden.bs.modal",function(){$(".ajax-button").button("reset").removeClass("ajax-button");$("#myModal").remove()})</script>', $this->group);
	$oscTemplate->addBlock('<script>$(".tooltip_cookie").tooltip()</script>', $this->group);

	}

    function isEnabled() {
      return $this->enabled;
    }

    function check() {
      return defined('MODULE_FOOTER_SCRIPT_AJAXCART_STATUS');
    }

    function install() {
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Ajax Module', 'MODULE_FOOTER_SCRIPT_AJAXCART_STATUS', 'True', 'Enable the ajax cart?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_FOOTER_SCRIPT_AJAXCART_SORT_ORDER', '0', 'Sort order of script execution. Lowest is displayed first.', '6', '0', now())");
    }

    function remove() {
      tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
    }

    function keys() {
      return array('MODULE_FOOTER_SCRIPT_AJAXCART_STATUS', 'MODULE_FOOTER_SCRIPT_AJAXCART_SORT_ORDER');
    }
  }
?>




#1749688 The last straw (2.4 beta) Language system GIT

Posted by wHiTeHaT on 08 November 2016 - 09:17

osCommerce_Language_System approximately 99,9x% completed.

 

Current branch is merged with the osCommerce/oscommerce2 master and 6 commits ahead of osCommerce:master.

 

:thumbsup:




#1749496 The last straw (2.4 beta) Language system GIT

Posted by wHiTeHaT on 03 November 2016 - 08:29

  1. Documentation for v2.3.x Braintree App
  2. v2.3.x Braintree App tagged on Github
  3. Documentation for v2.4 Braintree App
  4. v2.4 Braintree App tagged on Github
  5. Documentation for v2.3.x PayPal App
  6. v2.3.x PayPal App tagged on Github
  7. Documentation for v2.4 PayPal App
  8. v2.4 PayPal App tagged on Github
  9. v2.4 OSCOM Framework Documentation
  10. Review and consider language definitions updates for inclusion in v2.4.0beta or to leave for v2.4.1beta
  11. v2.3.5 Package for testing
  12. v2.4.0beta Package for testing
  13. Release + Release Announcement

 

 

Review and consider language definitions updates for inclusion in v2.4.0beta or to leave for v2.4.1beta

 

This task is almost completed, the sooner it finished the easier is to merge it with the master.

Current language system is up to date with current oscommerce2 master.

 

So let's make the last changes together as it isn't rocket science almost anyone can do it.

 

You can find the osCommerce_Language_System branch right HERE

 

 

Thanks!




#1749432 Multiple Field Tick Box Filter

Posted by wHiTeHaT on 02 November 2016 - 12:33

http://addons.oscommerce.com/info/9374




#1748449 Oscommerce Actions handled by Hooks

Posted by wHiTeHaT on 12 October 2016 - 07:44

Just did some testings related on the following post by @burt :

 

http://forums.oscomm...erce/?p=1748128

 

As @kymation mentioned the hooks class for running site actions (form submits or general CRUD actions), i took the challange for testing the idea.

 

I can tell you it works.

I will later post the files here for testing and refine the code after "we" inspected and verify the code.

 

A simple example code to give you an idea:

 

application_top (removed the switch/actions code and replaced with 1 line only) :  

Registry::get('Hooks')->call('Actions', $_GET['action']);

The hook code for add_product:

namespace OSC\OM\Module\Hooks\Shop\Actions;
use OSC\OM\OSCOM;
class add_product
{
    public function execute() {
  global $messageStack;
 
  if ( DISPLAY_CART == 'true' ) {
   $goto =  'shopping_cart.php';
   $parameters = array('action', 'cPath', 'products_id', 'pid');
  } else {
   $goto = $PHP_SELF;
   if ( $_GET['action'] == 'buy_now') {
    $parameters = array('action', 'pid', 'products_id');
   } else {
    $parameters = array('action', 'pid');
   }
  } 
  if (isset($_POST['products_id']) && is_numeric($_POST['products_id'])) {
   $attributes = isset($_POST['id']) ? $_POST['id'] : '';
   $_SESSION['cart']->add_cart($_POST['products_id'], $_SESSION['cart']->get_quantity(tep_get_uprid($_POST['products_id'], $attributes))+1, $attributes);
   $messageStack->add_session('product_action', sprintf(PRODUCT_ADDED, tep_get_products_name((int)$_POST['products_id'])), 'success');
  }
 
  OSCOM::redirect($goto, tep_get_all_get_params($parameters));
}
}



#1735888 KissIT Image Thumnailer

Posted by wHiTeHaT on 11 November 2015 - 09:29

Little suggested improvement :

 

admin/includes/functions/general.php :

 

Replace :

// Function to reset KISSit image thumbs cache entries
  function tep_cfg_reset_thumbs_cache( $action = 'false' ) {
  	if ($action == 'reset' ) {
    $dir = '../' . DIR_WS_IMAGES . KISSIT_THUMBS_MAIN_DIR;
    tep_destroy_thumbs_dir($dir);
    tep_db_query( "UPDATE configuration SET configuration_value='false' WHERE configuration_key='KISSIT_RESET_IMAGE_THUMBS'" );
    }
  }

With :

// Function to reset KISSit image thumbs cache entries
  function tep_cfg_reset_thumbs_cache( $action = 'false' ) {
  	if ($action == 'reset' ) {
    $dir = DIR_FS_CATALOG_IMAGES . KISSIT_THUMBS_MAIN_DIR;  //i use the direct path
    if (file_exists($dir)) { //i check first if it exists, cause if 2 times execute reset in admin you get a error warning. The check prevents to output the warning.
        tep_destroy_thumbs_dir($dir);
    }
    tep_db_query( "UPDATE configuration SET configuration_value='false' WHERE configuration_key='KISSIT_RESET_IMAGE_THUMBS'" );
    }
  }



#1735016 SPPC Lite

Posted by wHiTeHaT on 15 October 2015 - 10:33

ok... played a little with it , this is what i came up with.

 

The problem to return parents data is because the class is stored into an object into the database (sessions);

 

So i did the following(how you update the sessions values is your concern) :

application_top.php :

    // include shopping cart class
    require(DIR_WS_CLASSES . 'shopping_cart.php');
    require(DIR_WS_CLASSES . 'shopping_cart_mod.php'); 

new class:

<?php
    
    class shoppingCartMod {
        public $contents;
        public $total;
        public $weight;
        public $cartID;
        public $content_type;
        public $cg_id;
       
        
        public function __construct() { 
            global $cart;
            $this->contents = $cart->contents;
            $this->total = $cart->total;
            $this->weight = $cart->weight;
            $this->cartID = $cart->cartID;
            $this->content_type = $cart->content_type;
            $this->cg_id = $_SESSION['sppc_customer_group_id'];//i cannot test this
        }        
        
        
        public function get_quantity($products_id) {
            if (isset($this->contents[$products_id])) {
                return $this->contents[$products_id]['qty'];
                } else {
                return 0;
            }
        }
        //Here you could update the $cart data, but you need to go figure out yourself. I not intend to write all the code for you.
        public function set_quantity($products_id) {
            if (isset($this->contents[$products_id])) {
                return $this->contents[$products_id]['qty']+10;
                } else {
                return 0;
            }
        }         
        
    }
    
?>

in catalog/shopping_cart.php load  the new class :

    require("includes/application_top.php");
    
    if ($cart->count_contents() > 0) {
        $cartMod = new shoppingCartMod();

        include(DIR_WS_CLASSES . 'payment.php');
        $payment_modules = new payment;
    }

Then use it as you want ... for example:

var_dump($cartMod);
                        $products_name = NULL;
                        for ($i=0, $n=sizeof($products); $i<$n; $i++) {
                        
                            echo '<strong>##########' . $cartMod->set_quantity($products[$i]['id']) . '########</strong><br>';//Here we do stuff with the new class
                        
                            $products_name .= '<tr>';
                            
                            $products_name .= '  <td valign="top" align="center"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '">' . tep_image(DIR_WS_IMAGES . $products[$i]['image'], $products[$i]['name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a></td>' .
                            '  <td valign="top"><a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']) . '"><strong>' . $products[$i]['name'] . '</strong></a>';
                            
                            if (STOCK_CHECK == 'true') {



#1734298 Easy template style proposal for v2.3

Posted by wHiTeHaT on 25 September 2015 - 11:46

@raiwa, yes it is better to include little css rules when an add-on does not require that much css.

 

This technique could also solve Google's new "Above the fold" checkup.




#1734296 Tax Information

Posted by wHiTeHaT on 25 September 2015 - 11:41

@raiwa , i think these functions fulfilled in the past their purposes, as soon there will be a product class, these kind of functions going to be obsolete.

(Retrieving data via a cached class would reduce the db calls)

 

On the other hand these kind of functions can also be extended to load an array of product_id's, but still requires many unneeded server resources.

As there are currently not much other options provided from out of the core it is up to you to either use it or make your own optimized code.




#1734293 Easy template style proposal for v2.3

Posted by wHiTeHaT on 25 September 2015 - 11:24

@raiwa , the theory is correct ( i not tested your code).

 

In previous topics this issue was discussed, (EDITED: i just read the older topics here.... so this is infact the topic about it haha)  nice you made a solution for it without touching core files.

 

It is also a good alternative to load specific module based CSS rules/files.

The problem i see is that if there will be more add-ons and they all use a kind of the above code we going to waste server resources.

 

But yes, for a single add-on, and currently no core solution is provided, i would say go for it.But keep the critic in mind.




#1731167 Addon Development - Best Practices

Posted by wHiTeHaT on 08 July 2015 - 16:41

I think this is based on a misconception, let me try this time by the wisest and not personal (and i excuse me for might be hurting peoples feelings in the past, still my intentions are for the best of all of us, i hope you can as easily forget/forgive as i).

 

 

osCommerce is meant for people who want to DIY

 

There is no reason to think that this will not be the case anymore, even the contrary is the case when the developers would have heads up together.

I see a community version as a statement to the main developers, like a public petition signed by most of the locals of a area and is handover to their local government.

It is a sign to the government that there is action required.

 

The only mistake in thinking that could occurs to some people, is that osCommerce's responsibility against their users is the same as your local government.

For anyone who thinks it should be like that, i strongly recommend to stop thinking as a businessman.

I sometimes think that most of you apply the same thoughts as how you run your business, and that these same thoughts apply to osCommerce, but it simply is not the case, i think it is very very important to keep that in mind each time you think must give criticism.

 

On the other hand, i understand it,because osCommerce affects your business, so the relation is made fast.

 

Back to the point of heads up together and offer/build a community version as how @burt already made a very good start on.It is a proof for me that building a community version has the desired effect you all so wanted badly.

The trust in it is so positive, that the ones who on the forum most frequently, redirect or strongly recommend the community build version to anyone new to the community.

 

And here is where it hurts, i go now speak in terms of WE as the ones who contributed/supported the code, as i think i am a part of these few.

It feels like you get back-stabbed by the people for who you did it, for me personal i enjoyed getting some recognition, most of it i got from @burt himself, not even a hand-full here on the forum, but yes.... many and very often from the people in the chat, i dear to say they stand-up for me as they are aware of my intentions, but mostly ..... respect my vision i have in things.

Now it is not me who is after getting credit, but yes of course it is flattering.

But it is most important WE want you to understand we do all that FOR YOU......FOR FREE, we are not doing this for osCommerce on the first place..... but for osCommerce on the last place.

However osCommerce eventual will profit from it.

 

Please get the thoughts out of your minds that you think we (the community dev's) or osCommerce, MUST anything for you.

If not, then yes, the answer will be DIAY (Do It ALL Yourself).

Because i am a nut-case spending so much time on osCommerce, as i not even run a store, and even payed community contribution (why the hell would i do that?....and yes.... currently i can't even afford the €10,- for it..... i not even have money to buy some good food, but still i must pay for the internet, as that is simply a requirement in our country , as all is here digital....else you not exist) But most important is, i want to contribute to something i support, just with the hope in the end i can pick the fruits from my efforts, so it is very important for me personal that you get decent code.

You can ask behind my back how i fought for you with @burt, try to somehow convince him with some of my ideas i had, picked up here and there in some forum posts.

Keep in mind HE DID THE EXACT SAME FOR YOU to convince the staff of your needs.

 

So..... i want to end this a conclusion you can take from this post, but for me it is a fact.

 

We really have the best interest for you (and trust me..... we are pretty smart), and not to fill our pockets.




#1730746 osCommerce languages from database

Posted by wHiTeHaT on 29 June 2015 - 14:06

Idea for installing add-ons (XXX could be read as 'specials') :

 

add_on_XXX.zip

unpack contents to directory add_ons

directory add_on_XXX contains :

 

header_tags/ht_XXX.php

boxes/bm_XXX.php

hooks/HOOK_XXX.php

admin_boxes/adm_pg_XXX.php

language/add_on_XXX.ini

 

No more installing/de-installing from modules->boxes, modules->content, modules->shipping , but only activate/de-activate and sort ordering. (so a limited single control)

 

New admin page add_ons.php list ALL add-ons :

you will see:

 

Author name of the add_on  (required)

Author website (optional)

add_on support link (optional)

add_on Version (required)

 

install/de-install/enable/disable/settings managing/language editing for each ht_,bm_,cm_,HOOK_ etc  thats comes with the add-on.

 

This simplifies control of your add-ons.




#1730414 Gold / Edge - Is this post still good?

Posted by wHiTeHaT on 20 June 2015 - 18:13

There is no need to talk about as it is not of your concerns.

 

 

You and many other constantly attacking oscommerce (==Harald)....Still......... you all keep using it?

So yes of course i getting personal.

 

 

 

A simple solution for you... as you are a hosting guy.............

Change the oscommerce 2.3 on your 1-click install solution to the bs version.... one under your control.

 

Question......... is on that 1-click install also a ZEN-Cart?

I not see an official download here on osc for it?

still it is oscommerce....... whatever they call it.

 

There are a bunch of peep always the same ones..... oscommerce would be better without with, as they add NOTHING constructional to it.

 

They all forget oscommerce is FREE and you can do as YOU PLEASE with it... you have no right what so ever to insist/demand ANYTHING from it's developers.

 

If H makes damage to osc......let him it is HIS.... we are not his social-workers.

 

Simply use it......... discuss it's functionality.......discuss add-ons.......... but leave the owner and what he do with it  out of your discussions......... stick to the code..

I was pissed to.sure.... but i got over it very fast........

 

You all should

 

All these post like this ones (if i had control over them).......... they should be removed........... and anyone ever start such again.......... should be banned.




#1730403 Gold / Edge - Is this post still good?

Posted by wHiTeHaT on 20 June 2015 - 16:07

Breakfast == Official version

Lunch = Un-official version