Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

Adding fields to mijoshop via auto action

  • trovato83
  • trovato83
  • OFFLINE
  • Posts: 8
  • Thanks: 2
  • Karma: 1
11 years 7 months ago #223371 by trovato83
hi there, i just installed mijoshop and CB and would like to auto add the address fields from the registration of CB to the address fields of mijoshop. it adds the user etc but not address or other extra fields.
here is my code in auto action. (sorry, not that good with code)
Code:
$myuserid = SELECT MAX( user_id ) FROM `#__comprofiler`; $address = SELECT `cb_address` FROM `#__comprofiler` where `user_id` = '$mysuerid'; $addressid = SELECT MAX( customer_id ) FROM `#__mijoshop_address`; UPDATE #__mijoshop_address SET `address_1` = '$address' where `customer_id` = '$addressid';
joomla 2.5.9 cb 1.9
also attached a screenshot of the auto action plugin.
Attachments:

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48459
  • Thanks: 8280
  • Karma: 1443
11 years 7 months ago #223391 by krileon
Replied by krileon on topic Adding fields to mijoshop via auto action
That's not a valid query. You can't mix PHP inside of a query. Please see the below set of tutorials regarding SQL.

www.w3schools.com/sql/sql_intro.asp

You write the queries in the same way you would if you were using them in phpmyadmin with the exception that instead of your table prefix you use #__ and that substitutions can be used as well (e.g. `user_id` = '[user_id]').

The below will probably work. Am not familiar with that extensions database and is purely based off what you have already provided and am guessing customer id within your extension is user id (the ID as seen in _users and _comprofuler).
Code:
UPDATE `#__mijoshop_address` SET `address_1` = '[cb_address]' WHERE `customer_id` = '[user_id]'

Note the above is just an update query. If the row doesn't exist it won't do anything.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

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

  • trovato83
  • trovato83
  • OFFLINE
  • Posts: 8
  • Thanks: 2
  • Karma: 1
11 years 7 months ago #223625 by trovato83
Replied by trovato83 on topic Adding fields to mijoshop via auto action
INSERT INTO `wrkr1_mijoshop_address`
( `customer_id`, `firstname`, `lastname`, `address_1`, `city`, `postcode`)
(SELECT `user_id`, `firstname`, `lastname`, `cb_address` , `cb_city` , `cb_postalcode`
FROM `wrkr1_comprofiler`
WHERE `user_id` = (
SELECT MAX( `user_id` )
FROM `wrkr1_comprofiler` )
)

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48459
  • Thanks: 8280
  • Karma: 1443
11 years 7 months ago #223696 by krileon
Replied by krileon on topic Adding fields to mijoshop via auto action
That's not correct again. Why are you using a select query for user id? That's just going to pull the last user row in your database and not the current user row. Please see my above reply. You should be doing the below.

WHERE `user_id` = '[user_id]'

In your usage if you had 2 people register at the same time then 1 would not working. Please ensure you're using the above so it is absolutely specific to their user id.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

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

Moderators: beatnantkrileon
Powered by Kunena Forum