Custom Field Adding From External PHP Program

  • Posts: 11
  • Thank you received: 0
10 years 1 month ago #202949

-- url of the page with the problem -- : 173.192.186.130/~expaz/chooseletters.php
-- HikaShop version -- : 2.4.0
-- Joomla version -- : 3.3.6
-- PHP version -- : 5.4.29

Hi, I am having some problems trying to create a custom field in an external php program and then add it to the hikashop cart. The external php program is creating the field and the cart is being updated but the custom field is not. The external program is doing what I expect - creating letters from the word entered but getting that info into the cart so that it can go to checkout isn't set up properly and I am trying to understand how to do this more easily.

I haven't programmed in a long time. I have read the forums but don't know all of the ins and outs of hikashop programming.

I purchased the commercial version which allows for custom fields. The custom fields have been added into hikashop. But trying to add the field to the cart is causing me problems. The field is called 'word'. It is the total word added when a visitor creates a word from letters.

Thanks for your help.

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

  • Posts: 13201
  • Thank you received: 2322
10 years 1 month ago #202954

Hi,

As I can see, you transform one letter into one product in the cart, what is the custom field information for ?
To specify the code of the image used ?

If it is, so as you said you have to create a custom field in the product table, then when adding a product to the cart, populate the database column with the custom field name with the desired value. Then edit the view "checkout / cart" and for each product display the value of the custom field, you can use code to display an image directly in the cart.

www.hikashop.com/support/support/documen...ize-the-display.html

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

  • Posts: 11
  • Thank you received: 0
9 years 11 months ago #209663

I realize I have been absent for a while but I am still working on this project. I am trying to find out how to send the custom field data value to hikashop. I set up the custom field in hikashop (word) but my php program is where the value comes from. What is the variable that I use to send the value of "word" with the custom field "word" in hikashop.

Thanks

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

  • Posts: 26256
  • Thank you received: 4041
  • MODERATOR
9 years 11 months ago #209664

Hi,

I'll recommend you to use the trigger "onBeforeCartUpdate" and then modify dynamically the item to set the custom field value.
www.hikashop.com/support/support/documen...umentation.html#cart
You can otherwise use other cart triggers and perform a database query to update the custom field value directly in the database (thanks to the cart_product_id or the order_product_id if you're using order triggers).

And the variable is just the namekey of your custom field (so the column name in the database).

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 11
  • Thank you received: 0
9 years 11 months ago #209855

This seems like a small task what would you charge to fix this for me? I just don't know the syntax and where to put everything to make this work.

thanks

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

  • Posts: 11
  • Thank you received: 0
9 years 11 months ago #209857

Oh, what I need is to add the 'word' (custom field) and the images (custom field) for the letters to the database that are associated with the letters chosen. The images need to display on each line with the letters. The word can display either before the letters on repeat on each line with each letter.

Also, if another word is added to the cart before checkout, then that 'word' and those images also need to show in the cart with the associated letters.

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

  • Posts: 26256
  • Thank you received: 4041
  • MODERATOR
9 years 11 months ago #209897

Hi,

I'm sorry but I don't understand your last message and it does not sound as small task for my point of view.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 11
  • Thank you received: 0
9 years 10 months ago #213960

I have more questions concerning this project. I am taking a different approach and believe I have a solution. However, I have questions about the email notification. Can the data from the custom fields (there will be 2 custom fields and they will be added to the order and cart) be included in the email notification? Is this standard from hikashop or is programming required to change the information that the email notification will display in the email?

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

  • Posts: 26256
  • Thank you received: 4041
  • MODERATOR
9 years 10 months ago #213963

Hi,

Order and Item custom fields are displayed in emails (if they are configured to be displayed in the front-end).

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 11
  • Thank you received: 0
9 years 10 months ago #214070

thank you. another question - we are bringing in from the external program a custom field - word. however, the price of that field can vary based on some options the customer chooses. can we override the price in hikashop instead of using the product price set in hikashop for that custom field? if so, how do we do that?

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

  • Posts: 84079
  • Thank you received: 13628
  • MODERATOR
9 years 10 months ago #214076

Hi,

You can use the same principle as the donation plugin in order to override the product prices during the checkout:
demo.hikashop.com/index.php/en/hikashop/...t-page/donation-page

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

  • Posts: 11
  • Thank you received: 0
9 years 9 months ago #214146

Ok, now suppose I want to have a customer be able to add multiple words in the same session. Each word will have a different number of letters and will have a different price. So, there will be multiple 'words' in the shopping cart but not increase the quantity. Is this possible?

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

  • Posts: 84079
  • Thank you received: 13628
  • MODERATOR
9 years 9 months ago #214147

Sure. You can calculate the product price the way you want in your plugin. The donation plugin is just a simple example, but you can have any kind of calculations based on whatever is entered in the custom item fields of the products.

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

  • Posts: 11
  • Thank you received: 0
8 years 9 months ago #251344

I am now working on this again. I got some help to get the field 'word' into hikashop but we never went live and the return url is using an ip address that has changed. how do i properly set the return url?

Below is the code that the external php program is using.
<input type="hidden" name="return_url" value="aHR0cDovLzE3My4xOTIuMTg2LjEzMC9%2BZXhwYXovaW5kZXgucGhwL2hpa2FzaG9wLW1lbnUtZm9yLXByb2R1Y3RzLWxpc3RpbmcuaHRtbA%3D%3D">

Thanks

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

  • Posts: 84079
  • Thank you received: 13628
  • MODERATOR
8 years 9 months ago #251363

Hi,

Go on the website www.base64encode.org/ and paste the URL you want in the first textarea and click on the "encode" button.
Then, copy/paste the base64 encode URL in the text area below to the value of your hidden input field.

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

  • Posts: 11
  • Thank you received: 0
8 years 9 months ago #251434

I did what you suggested and encoded the url however, it still doesn't work. It is not returning to the cart as it should. It did work before the ip address of the website changed. What else should I look for?

To return the values to the cart is there a different url I should be connecting to? I am using the below form action in the php program.
<form action="/~expaz/index.php/hikashop-menu-for-products-listing/product/updatecart.html" method="post" name="hikashop_cart_form">

Thanks

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

  • Posts: 11
  • Thank you received: 0
8 years 9 months ago #251441

Also, in looking at the error message I see it says uncaught: TypeError: cannot read property 'callStatus' of null chooseletters.php" 383

In looking more closely at this part of the code there is a if(response.data.callStatus == 'Error') statement. What would cause this error.

Thanks

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

  • Posts: 84079
  • Thank you received: 13628
  • MODERATOR
8 years 9 months ago #251435

Hi,

There is nothing else to look at. It's this parameter where you can put the return URL and it has to be base64 encoded.
If it doesn't go to that URL then you have a problem with your code or the URL you based64ed.
Not knowing your code, I can't say.

And there is no callStatus in the code of HikaShop nor any file called chooseletters.php
So it really seems that the problem comes from your custom code.

Last edit: 8 years 9 months ago by nicolas.

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

  • Posts: 11
  • Thank you received: 0
8 years 8 months ago #253045

I found the problem with my earlier problem and it was a problem with code in one of the joomla modules. Now I am looking at the cart section of hikashop. I have 2 questions:
1) is there a way to eliminate the reference to VAT and to stop hikashop from adding dollars for VAT. I have looked and don't see where this can be changed. I guess I am just overlooking it. Can you clarify.

2) when returning from chooseletters, the info is going into the cart and checking out properly. i have 2 shipping options which the customer can choose and this shows up properly. However, if after the word is put into the cart, the customer goes back to choose another letter to add to the cart instead of completing the purchase, hikashop requires the customer to choose another shipping option. How do I change this to have the customer choose the shipping once instead of for each item being purchased.

Thanks

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

  • Posts: 84079
  • Thank you received: 13628
  • MODERATOR
8 years 8 months ago #253050

Hi,

1. The VAT is added by HikaShop to your prices based on how you configured the tax rules in the menu System>Taxes. Disable them if you don't want any taxes.

2. HikaShop only has one set of shipping methods for the whole cart, unless the products in the cart are in different warehouses and in that case, there will be one shipping method selection for each warehouse.
So if you have twice the same product in the cart, I don't see why you would have several shipping methods section areas.
Could you do a screenshot of the settings of your shipping methods listing, of your product and provide the instructions in order to reproduce the problem on your website ?

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

Time to create page: 0.065 seconds
Powered by Kunena Forum