Kryptronic Software Support Forum

You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.

#1 01-03-2017 11:19:48

zanart
Member
From: bedford
Registered: 04-02-2008
Posts: 1706

Remote Add Form

HI NIck
What's the score with the remote add functionality?
I see the functions have been removed from ECOM_Cart

I will be using inventory items with dynamic pricing.

I could use the standard ajax add to cart, but I cannot force the price change by updating the form.

Is there a way to update the price that is passed to the addcart function, probably before $this->globals('ecom.prod_proddisp',$prod); is updated in prodlist.php

or will I need to modify the addcart function to get the dynamic price?

It looks like ECOM_Cart gets the pricing from the database, not the form???


Rob

Offline

 

#2 01-04-2017 09:13:57

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Remote Add Form

Remote add to cart has been removed from K9.  It was no longer a fit with the new setup, most (if not all) functionality was ported somewhere to obsolete it, and I never really liked the security implications related with it.  Remote add to cart was a throwback to circa-1999 style ecommerce.  Enough said on that.

Now onto your issue.  You sell picture frames and used the remote add to cart previously to calculate price.  Your situation specifically, as you are a valued client, was considered while programming K9.  There are several ways to accomplish what you want, and knowing you get elbow deep in the code, I've put goodies in there for you along the way to help.  The following would be my recommendation:

(1) Create a option using Store / Catalog / Options.  Call that option 'Frame Dimensions' and give it a nice description.  Make it a required textbox option.

(2) Access System / Database / Raw Database Admin and browse the ecom_prodoptions table.  Update the option you just created.  Enter 'ecom:customframedims.php' for the 'fieldinclude' column's value.

(3) Download a copy of the file {private}/core/CORE/includes/formfield_textbox.php, save it as customframedims.php, and upload to {private}/apps/ecom/ECOM/includes.  Mod the file as needed so that your customers can select/choose/draw/whatever their frame.  I would make the main form field for the option hidden, and populate the hidden field value with a nicely formatted rendition of the LxWxH they've selected.   I'd also add another hidden form field for a final price.  So you're displaying a custom interface to allow proper selection, and you've got two hidden form fields to be posted in.  You can probably use a generic name/id for the price field, as I imagine this option will only show up once per page, per offer.  Call it 'pricecalc'.

(4) Open {private}/apps/ecom/ECOM_Cart/ECOM_Cart.php for editing.  Locate the addcart() function and find the section commented 'Process add to cart'.  It looks like this:

Code:

     $addcartreq = array('addtype' => $addtype, 'savetype' => $savetype, 'offer' => $offer[$offerid]);

     if (!(empty($reqquan))) {$addcartreq['reqquan'] = $reqquan;}

Right below that, add this:

Code:

     if ($this->globals('core_cgi.pricecalc')) {$addcartreq['forceprice'] = $this->globals('core_cgi.pricecalc');}

The cart will end up with the offer in it, with the dimensions selected showing as an option, and the correct pricing based on what was calculated realtime for the item as added to cart.  Does that work for you?  There are a few other ways to do this as we get deeper into it.


Nick Hendler

Offline

 

#3 01-04-2017 10:16:18

zanart
Member
From: bedford
Registered: 04-02-2008
Posts: 1706

Re: Remote Add Form

Thanks Nick. That's got me on track.

Can you give me some pointers on the Custom Data fields in Inventory/Options. Not sure if I could use this option.

The problem with using options is that the Add To Cart button is hidden when viewing Catshow. I am sure I can overcome this...
However, I think it would be easier if I just add some fields that I can retrieve in addcart_internal and add to $addcartreq['addparams'].
Adding fields to prodlistitem.php don't seem to be passed to addcart_internal??


Rob

Offline

 

#4 01-05-2017 03:49:58

zanart
Member
From: bedford
Registered: 04-02-2008
Posts: 1706

Re: Remote Add Form

I think I have cracked the code and got what I need!
I have had to change prodlistitem so it uses the form based add to cart method, not the quick add method. I expect this goes against what you were trying to achieve by not having lots of forms on the same page, but at the moment it looks like my best option if I want dynamic pricing on the cat show page. I may look at adding my size options to the quickadd link, and then sorting those values in ECOM_Cart.

Here's my work in progress - http://www.robzanna.co.uk/Category/Dark … ure-Frames

At the moment I prefer my pop up filter with multi selection, but realise it will probably need to be hidden on small mobile devices.

I have also changed the prodsort options so they are form based ajax refresh, instead of links with parameters.


Rob

Offline

 

#5 01-05-2017 09:18:25

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Remote Add Form

Very nice.  Like I said, there's a ton of ways to do it.  I assumed the adds were happening on the offer detail page.  I did eliminate the forms on those and went to a quickadd link, so as to clean up the HTML, as well as give options to add items from outside URLs using simple links (ala remote add to cart).

Concerning that filter, it wasn't very apparent to me at first how to change the sizing of the frames I was viewing and the filter seems to be the only way to do that.  If I were you, I'd move those inputs into each product offer list display, and allow editing right there, or make a big bold callout at the top.  Just a suggestion, awesome work so far.


Nick Hendler

Offline

 

#6 01-05-2017 09:19:37

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Remote Add Form

Oh, and to hide something on mobile is easy.  Just wrap it in a div classed like this:

Code:

<div class="kdispmid kdispwide"></div>

Nick Hendler

Offline

 

#7 08-08-2017 20:15:56

sppars
Member
Registered: 01-25-2006
Posts: 301

Re: Remote Add Form

I've been working on V9 for a few weeks now and am very disappointed to read from this post that Remote Add has been removed.

Remote add was very useful for our purposes because it allowed so much flexibility. Even though I haven't fully dived into the alternative solution, I can see how it can be made to work from an option selection that dynamically changes the price. However, one of the things that made remote add great for our purposes was once an option was selected, not only did it allow us to change the price but we were able to change the shipping parameters based on the inputted selections. In other words, remote add essentially allowed having a dynamic price and dynamic shipping fields (box dimensions, weight, number of items in a box, zip code it was shipping from and shipping method).

I don't see how the dynamic shipping aspect would be obtainable with the solution offered. Do you have any suggestions Nick?

Thank you.

Offline

 

#8 08-09-2017 07:03:52

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Remote Add Form

The solution in K9 that replaces the old remote add to cart functionality is to allow you to set up a product offer with various options and an optional customer input price.  K9 is an inventory based system and will not accept inventory purchase requests for inventory that doesn't exist, so the old method of being able to feed in inventory and shipping parameters is not possible.

For your situation, we'd need to know exactly what you're doing.  Perhaps building a few product offers that are package deals or custom packages out of inventory does what you used to do with remote add to cart forms, but better.  So what are you doing exactly?


Nick Hendler

Offline

 

#9 08-09-2017 21:27:49

sppars
Member
Registered: 01-25-2006
Posts: 301

Re: Remote Add Form

Nick,

We use remote add in two ways:

1st Method - Very simple remote add of samples for the product. Code for remote add is in "product display" and pulls information from the database item to generate code. You can see it live in action  under the product image. I think this should be achievable with Inventory Item AddOns.

2nd Method - More complicated because product is made to order and has 4 tiers of options with each selection impacting the price and shipping. I was working on it in V8, before deciding to upgrade to V9. You can see a work in progress example . In this method, the database holds the first tier option (design) as a "display" item. The rest of the options are built out with remote add code in the "product display" based on the information of the "display" item.

In V9, I can see the first tier (design) being the product offer, and the 2nd tier (size - impacts shipping & cost) being inventory items. The third tier (finish - impacts shipping & cost) would be options to the inventory items. This is where it gets tricky because I can have the cost change, but not shipping. The forth tier (2nd finish option - impacts cost).

Ideally, all of this would need to be presented in a clean way too, as it can't just be a list of options running down the whole page. In V5.1 we did remote add and it was easy for customer to navigate, in V6 we went to a database format, which resulted in creation of too many items and being confusing. In V8 and V9 I was hoping to use remote add with an item as "display" to make it very easy.

What are you thoughts and suggestions? How hard would it be to mod back in the remote add?

Also, I can't seem to find min and max quantities in V9, did they get dropped too?

Thanks.

Offline

 

#10 08-10-2017 01:17:33

zanart
Member
From: bedford
Registered: 04-02-2008
Posts: 1706

Re: Remote Add Form

I use V9 in a similar way for custom picture frames.

Do you use the inventory levels? I don't as I have added my own stock levels in the ecom_prod table as I only really want the products, not inventory.

I created an product and inventory item for every picture frame as this is what the software requires , but the inventory item/price was just for a sample. This means you have the product/inventory item in the database so it can be used in product lists and displays - click or hover over any item to view the Order Sample option https://www.easyframe.co.uk/category/bl … ure-frames

I then created a single custom product/inventory item. This single product has every field/option updated based on user input, and the price is dynamically updated as changes are made.
If you change the options here: https://www.easyframe.co.uk/picture-frames you will see the price is updated and the add to cart form is updated accordingly.

It can be done, but you need to delve deep into the core code.


Rob

Offline

 

#11 08-10-2017 08:11:05

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Remote Add Form

Method 1: I think setting those samples up as inventory items then using them as addons on product offers is exactly what you want to do there. 

Method 2: Look at custom packages of inventory items.  You can group them and make different selections.  Might be what you want to do.  I'm not sure if those particular panels are inventoried by finish or not, but if not, then those custom panels could use options for finish to do what you need to in a different way.


Nick Hendler

Offline

 

#12 08-10-2017 21:59:10

sppars
Member
Registered: 01-25-2006
Posts: 301

Re: Remote Add Form

Nick and Zanart thank you for the feedback.

Zanart, I really like how you have put everything together and I think the way you're handling samples is perfect for us too.

I'm a bit confused on how you got the custom product/inventory item to work. When I click on the "frames" and you have your list, where are those frames coming from, are they actually tied into database as inventory items. If so, can you give a bit more detail on how you were able to achieve that?

Thanks.

Offline

 

#13 08-11-2017 05:14:55

zanart
Member
From: bedford
Registered: 04-02-2008
Posts: 1706

Re: Remote Add Form

I have created a product offer and inventory item for each picture frame.

The frame designer page you we're looking at is a completely custom web page, but the frame lists are all pulled from the ecom_prod table.

The web page basically builds an add to cart form based on user selections. All the data and dynamic price is passed to ECOM_Cart when the form is submitted.

It requires major hacks that I certainly wouldn't encourage and would be frowned upon by Nick! but it can be done.

You can create a basic remote add form with a few extra hacks. Code below is for a basic add to cart form. You must create a product and inventory item with the correct id(I used 'custom1')

Code:

<?php

$this->globals('core.quickform_margin_none',1);
$formid  ='ecom--addcart';
$fields = array('SUBMITVALUE' => 'CART',
                         'referns'     => 'display',
                         'referref'    => 'custom1',
                         'offerid'     => 'custom1',
                         );

$this->xhtml_quickform_header('ecom--addcart','ecom','addcart',$fields);
     
print '<input type="hidden" name="pricecalc" id="ecom--addcart--pricecalc" value="111111" />';
print '<input type="hidden" name="ecom--addcart--pricemapid" id="ecom--addcart--pricemapid" value="DEFAULT-custom1-DEFAULT-custom1" />';
print '<input type="hidden" name="ecom--addcart--quantity" id="ecom--addcart--quantity" value="1" />' . $eol;

print '<button type="submit" id="' . $formid . '--SUBMIT">Basket</button>';


$ajax_extras = '{\'ecom_skinwidget_minicart\': {\'app\': \'ecom\', \'ns\': \'skinwidgetsid\', \'ref\': \'ecom.skinwidget_minicart\'}}';
$ajax_params = '{\'primary\': \'' . $this->xhtml_encode($formid) . '\', \'modal\': thisModalName, \'extras\': ' . $ajax_extras . ', \'formid\': \'' . $this->xhtml_encode($formid) . '\'}';
$js_docready = 'jQuery(\'#' . $formid . '\').submit(function(){var thisModalName = \'Shopping Basket\'; if (jQuery(\'#' . $formid . '--SUBMITVALUE\').val() == \'WISHLIST\') {thisModalName = \'My Gallery\';} return ajaxExec(' . $ajax_params . ');});';

$this->append_global_array('core.js_docready',$js_docready);
print '</form>';

?>

Post 2 above details the hack you need to make in ECOM_Cart.php to get the pricecalc field to override the inventory price when it is added to cart.

When you submit the above form, custom1 will be added to the cart with a price of 111111.


Rob

Offline

 

#14 08-11-2017 07:12:40

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Remote Add Form

It requires major hacks that I certainly wouldn't encourage and would be frowned upon by Nick! but it can be done.

This should have required a fairly minimal mod to one function, correct?  Everything else would have been auxiliary to the core code, like adding a web page with your own code in it.  I'm interested to know what was modded so perhaps I can point you to alternatives.  Like, for example if you modified {public}/media/scripts/common.js, I would have giving you a pointer on how to load a script in your skin to override anything done there, that also gets fired on page events.  We do like to keep mods to a minimum to make updating easier.  You will want to move to 9.0.2 when it releases.


Nick Hendler

Offline

 

#15 08-11-2017 09:17:43

zanart
Member
From: bedford
Registered: 04-02-2008
Posts: 1706

Re: Remote Add Form

I have got lots of hacks for lots of different things. Prodlist has extra controls for maximum frame sizes, my own stock control system which is automatically updated every 30 minutes, different prodfilter system & a completely different wishlist system. Far, far too much for me to even remember what I modded them for in the first place.
Common.js was modded for various reasons, and I replaced the v9 kmodal with bootstrap modal.
I also completely reworked the Batch Order module as the BSM didn't work for me, and the POS module has been heavily modified to work with my custom items.
Amazingly the site all works correctly and was launched today.

Just to be clear, there is nothing wrong with V9. I just found it easy to adapt it to my exact needs and wasn't in any rush to launch.

I am dreading 9.0.2. Please take your time!! I am sure it will be a hell of a lot a work for me, unless you have got a detailed change list.


Rob

Offline

 

#16 08-12-2017 03:18:11

sppars
Member
Registered: 01-25-2006
Posts: 301

Re: Remote Add Form

Thank you Zanart. That gives me a starting point... it does look like it will be code heavy though.

As a side, you may already be using it, but I've found  to be really useful in finding out what was changed between updates.

Offline

 

#17 08-14-2017 07:25:31

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Remote Add Form

Amazingly the site all works correctly and was launched today.
I am dreading 9.0.2. Please take your time!! I am sure it will be a hell of a lot a work for me, unless you have got a detailed change list.

Congratulations on the site launch! 

I have a feeling applying 9.0.2 is not going to be a big deal for you.  There are a lot of changes to a lot of files, but changes to areas which you have modified heavily are minimal.   Meaning you'll likely have to do a line-by-line compare with a utility and merge in changes, but there won't be a lot of different logic to figure out.  The areas you've modded are all new to K9 and remain pretty much unchanged as far as logic goes.  The widespread changes in 9.0.2 are mostly related to speed enhancements, resource usage optimization and security.  Session management and the account area has changed dramatically.  There are at last count 72 functionality additions and changes, major and minor.  I think you'll be pleasantly surprised, and there will be a detailed changelog.


Nick Hendler

Offline

 

#18 08-14-2017 11:22:31

zanart
Member
From: bedford
Registered: 04-02-2008
Posts: 1706

Re: Remote Add Form

Getting rid of SID's may cause be a few issues as I use them for user image galleries and storing various size data.
But there is always another way!


Rob

Offline

 

#19 08-15-2017 07:42:25

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Remote Add Form

So you can get your head around this early, the main changes were:

- SIDs were eliminated completely as far as cookies, URLs, forms and JavaScript.  They are completely missing from 9.0.2.  No URLs, forms or JavaScript reference any markers which would identify the browser.

- 9.0.2 operates with a single URL, whether that be SSL (preferred) or non-SSL.  The ability to run mixed-content was completely removed. 

- Most items which were previously stored in a generic session in core_sessions are now stored in their own dedicated cookies, generally session cookies, but there are a few exceptions with time-based cookies.  Items like breadcrumb history, sort choices, etc. are all now stored by the browser in a cookie.

- User accounts now have all session-based storage in the core_users table tied directly to their account.  Items stored here include cart references, checkout information, basically anything that needs to be stored for the user account that is not present elsewhere in the core_users table.  Users get a special access token cookie upon logging in that's good for the browser session that identifies them.

- In the event session storage is needed for a guest browser, like when a cart is created or they enter information like a name or email address, start checkout, etc., that session data is stored in core_sessions.  Guests get a special session token which identifies their session and persists for 30 days.

Great lengths were gone through to optimize all storage for very busy/large sites and to provide a more secure operating environment which was faster and met the needs of current browsers and the current security environment.  You should be able to accomplish whatever you need to by simply updating the session or setting your own cookie with a gallery id.  Either way you'll be leveraging the all-new CORE_Session, but it will feel familiar.


Nick Hendler

Offline

 

#20 09-13-2017 19:48:11

sppars
Member
Registered: 01-25-2006
Posts: 301

Re: Remote Add Form

Nick,

Would it be possible to mod the addcartquick function to add an inventory item directly to the cart? Or possibly have the reference include the pricemap to an inventory item from a product offer to perform a quick add?

Offline

 

#21 09-14-2017 07:39:17

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Remote Add Form

sppars: Can't you just ceate an offer for one of the inventory item priced correctly? Everything will would work for you.  I'm not understanding why this is not an option for you.


Nick Hendler

Offline

 

#22 09-14-2017 21:49:28

sppars
Member
Registered: 01-25-2006
Posts: 301

Re: Remote Add Form

Nick,

I've already worked that part out.

I was trying to do something similar to Zanart, with the samples. If I understand him correctly, he made the initial offer be the sample so when the quickadd link is being generated in the category sections it's for the sample.

In my situation, I have a pattern sample and a finish sample that would need to be both on the same page. Therefore, I can't really make the sample be the initial offer. The way the product offer is set up is by pattern and then every finish is an inventory item of that product offer - essentially the way you have designed product offers to work. Using custom data fields in the product offer and each inventory item I was able to take the long list of items and categorize them into nested jquery tabs, and the appearance now is identical to the V8 remote add, with very minimal modifications.

Now, I wanted to see if I can use the addcartquick function to generate a link for the samples, as each inventory item is being populated. I figured if I can have addcartquick take a pricemap reference it would be a quick clean solution.

And I know we talked about doing the samples as an addon, but the addon gets generated after the inventory items and I was trying to keep it clean and have a sample link under each main inventory item, instead of the sample options being at the bottom where the addon gets printed.

Nevertheless, I think I may have figured out a way of achieving this. I'll work on it and report back. If there is a way to have the addcartquick take a pricemap reference, please let me know.

Thanks.

Offline

 

#23 09-15-2017 06:12:48

zanart
Member
From: bedford
Registered: 04-02-2008
Posts: 1706

Re: Remote Add Form

When you say artcartquick function, are you referring to the art to cart function used in category displays whereby a href link adds to cart based on the prod id in the link?? If so, I think you would need different products for each sample as that method doesn't accept any options so you couldn't have 2 versions for the same id.

or do you mean you want to utilise the shopping cart modal pop up function?? If so, you can use this function via a form based add to cart method, or probably just by creating a ajax link with the correct params.


Rob

Offline

 

#24 09-15-2017 08:26:57

webmaster
Administrator
From: York, PA
Registered: 04-20-2001
Posts: 19798
Website

Re: Remote Add Form

The addcartquick namespace takes a product offer id as input and adds all the items associated with it.  In order to add pricemap entries, you need to post a full form to the main add to cart namespace, as zanart mentioned.  Have you looked at the Custom Page offer type?  Does that not do what you need it to out of the box?


Nick Hendler

Offline

 

Board footer