js id logic when add to cart in webpage

  • Posts: 846
  • Thank you received: 92
11 years 4 months ago #112730

hi

I have many questions. ...

1)
if i have 3 items ( with "add to cart" widget ) , each item must be identify using specificy id.
The script is base on hikashop_product_quantity_field_X , why not use X as the value of the column of __hikashop_product.product_id since X is unique even it can be not contiuous?
Is there many files and items to change in the php side to change $i to the product_id ? Is it possible ? ( don't break all logic)

2)
in which order appear the item when hikashop use X $i++ ?
There must be a SQL that let me show that ?
Does this can be change using the Joomla Back End GUI ?


2)
if the page contain only 1 item with add_cart widget , X=1 hikashop_product_quantity_field_X
X by default is continuous ( increment logic).So X are unique So why not use X=product_id ?
IS there a way to use product_id in the parameters of displaybutton define in cart.php ?

3)
the javascript use predefine id ( create in php side) why not use this.id as the first parameter of hikashopModifyQuantity(id, ....) ( is also use in html in name=[id]) .

4)
why identify product using class with layout column / row , why not product_id ?
<div class="hikashop_products">
<div class="hikashop_product hikashop_product_column_1 hikashop_product_row_1" style="width:32%;">
<div class="hikashop_product hikashop_product_column_1 hikashop_product_row_2" style="width:32%;">
since HS use Class that mean that this notation in only for CSS Layout manage by php ? right ?

5)
Is there many implementations of hikashopModifyQuantity(id,obj,add,form,type,moduleid)
I find this function with same parameters in two differents location of the same files - if else ...) ?
If i need to add new javascript function ...i need to copy my code in 2 differents location in the same phpfile inside same variable ? !!



I am not a javascript developper ....Soto i there is a reason to implement things like this ?

Last edit: 11 years 4 months ago by lionel75.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
11 years 4 months ago #113066

Hi,

1. Anything is possible if you're a developer. You would have to change the file administrator/components/com_hikashop/helpers/cart.php as well as all the places where $this->cart->display() is called in order to add the product_id information and be able to use it in the helpers/cart.php file.
Why we did it like that and not with the product_id ? The main reason is that this way you can have several add to cart buttons for the same product on a page and each one with its own quantity field. That wouldn't be possible with the product_id since both quantity field for the same product would have the same id and the system wouldn't pick the correct one all the time. Plus, it's not valid HTML if you have several times the same id on a page.

2. There is no particular order. The value is incremented automatically each time the display of an add to cart button is called on a page. It's not in the database and can't be changed in the backend.

2.bis As I explained on point 1, what if you have two products listing modules, with add to cart buttons, and their quantity fields displayed on the same page with potentially the same products ? X=product_id won't work in that case.

3. The id parameter of hikashopModifyQuantity is the product_id. hikashopModifyQuantity is called when you click on the add to cart button. The add to cart button doesn't have any id and if it had an id, it wouldn't be the product_id for similar reasons of point 1 and 2.bis. So you can't do what you said.

4. column/row classes can be necessary for some particular styling.
So far no one needed to style each box of a listing based on specific product_id, and we didn't see why it would be necessary, so we didn't add a class name for the product_id but we could if we wanted to.

5. There is two functions based on whether you're displaying a popup notice after the add to cart or not. You only use one or the other so you don't need to change both. And if you want to change that js function, it would be better to create a template override with the implementation of hikashop_cart_js_render as explained on our developer documentation so that you don't loose your changes to that function each time you update.

The following user(s) said Thank You: lionel75

Please Log in or Create an account to join the conversation.

  • Posts: 846
  • Thank you received: 92
11 years 4 months ago #113102

my problem is resolve ...
thank's for all your posts that let me learn a lot about hiskashop API.

Lionel

Please Log in or Create an account to join the conversation.

  • Posts: 846
  • Thank you received: 92
11 years 3 months ago #116054

in a past post, i understand that some php file can't be override. But i don't go futher after the reply ?
How we can detect that a php ll not support override ?
If yes , Is there a documentation ( some code ) to achieve this ?

Thank's ?

Last edit: 11 years 3 months ago by lionel75.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
11 years 3 months ago #116062

So for HikaShop product view files, it's a mechanism that is handled by joomla and you can do it by modifying the view files via the menu Display>Views in HikaShop.
For the rest of the files of HikaShop (classes, types, helpers, buttons), you should be able to override any of them by copying their file in the folder templates/YOUR_TEMPLATE/html/com_hikashop/administrator/FILE_NAME.override.php
And then, in the copy, you need to change the class name to add the Override suffix to it and the system will automatically load both classes and instiate yours (that way, you can actually extend from the original one and only add the functions that you want to change.

It's also possible to use a system plugin to instantiate the class you want to override before it and the system will then automatically use yours instead of HikaShop's default one.

So with all this, you should be able to override pretty much anything in HikaShop.

The following user(s) said Thank You: lionel75

Please Log in or Create an account to join the conversation.

  • Posts: 846
  • Thank you received: 92
11 years 3 months ago #116088

when study hiskashop code , it 's strange that custom code for Frontend have/can use code locate in the Frontend/Administrator Directory !

since it 's working like that and we can achieve what we want because documented why not ! !!?

thank's for all the informations .... i have to test/Study now ...

Last edit: 11 years 3 months ago by lionel75.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
11 years 3 months ago #116095

The helpers, classes and types files are common to the front and back end. Why duplicate the code if you want it to do the same thing on both the frontend and backend ?
For example, take the helper.import file. It is used by the backend import screen as well as the product cron update plugin which is run by the cron task on the frontend. If we were to duplicate the code, we would have to change the code at two places each time we change/add something in the import system.
It's a bit like the libraries folder of Joomla. It is common to both the frontend and backend of Joomla.

Please Log in or Create an account to join the conversation.

Time to create page: 0.071 seconds
Powered by Kunena Forum