- Dec 1, 2018
- 23,632
- 26,969
- 120
I'm currently working on a directory type site using Toolset.
A customer can purchase 3 plans (Classic, Premium & Deluxe) and each plan allows them to upload a certain amount of videos and images.
There are 3 separate forms for purchasing, 1 for each plan and I've enforced the video & image limits as follows....
They add they video/image one at a time as shown in these images...
Once the maximum number of videos/images they are allowed is reached the Add new button no longer appears. I achieved this using the following code...
So now on to my problem
....
The customer also has to have the ability to edit their listing but there is only 1 form available to do this regardless of their plan.
In this form I have a non editable field with their plan type pre-filled. The field is called 'wpcf-memorial-type'
So what I need, if possible, is the code above edited so that...
If the pre-filled value of 'wpcf-memorial-type' is Classic then...
If the pre-filled value of 'wpcf-memorial-type' is Premium then...
If the pre-filled value of 'wpcf-memorial-type' is Deluxe then...
Note I have no clue about jQuery & JavaScript so I don't even know if this is possible lol.
I hope you understand what I'm after and thanks in advance for any help
A customer can purchase 3 plans (Classic, Premium & Deluxe) and each plan allows them to upload a certain amount of videos and images.
There are 3 separate forms for purchasing, 1 for each plan and I've enforced the video & image limits as follows....
They add they video/image one at a time as shown in these images...


Once the maximum number of videos/images they are allowed is reached the Add new button no longer appears. I achieved this using the following code...
JavaScript:
jQuery(window).bind("load", function(){
var maxreps = {
'wpcf-memorial-videos': 2,
'wpcf-memorial-photo-gallery': 9,
};
jQuery(document).on( "click", ".js-wpt-repadd", function(e){
var $closest = jQuery(this).closest('.js-wpt-repetitive');
var isfile = $closest.find('input[type="file"]').length;
var name = isfile ? $closest.find('.wpt-repetitive-field:first input[type="file"]:first').attr('data-wpt-name') : $closest.find('.wpt-repetitive-field:first input:first').attr('data-wpt-name');
// how many repetitions?
if ( $closest.find('.wpt-repctl').length > maxreps[name] -1 ) {
// hide button to add more
jQuery(this).hide();
}
});
// add click listener to trash buttons
jQuery(document).on( "mouseup", ".js-wpt-repdelete", function(e){
var $closest = jQuery(e.target).closest('.js-wpt-repetitive');
$closest.find(".js-wpt-repadd").show();
});
});
So now on to my problem
The customer also has to have the ability to edit their listing but there is only 1 form available to do this regardless of their plan.
In this form I have a non editable field with their plan type pre-filled. The field is called 'wpcf-memorial-type'
So what I need, if possible, is the code above edited so that...
If the pre-filled value of 'wpcf-memorial-type' is Classic then...
JavaScript:
var maxreps = {
'wpcf-memorial-videos': 2,
'wpcf-memorial-photo-gallery': 9,
};
If the pre-filled value of 'wpcf-memorial-type' is Premium then...
JavaScript:
var maxreps = {
'wpcf-memorial-videos': 3,
'wpcf-memorial-photo-gallery': 19,
};
If the pre-filled value of 'wpcf-memorial-type' is Deluxe then...
JavaScript:
var maxreps = {
'wpcf-memorial-videos': 4,
'wpcf-memorial-photo-gallery': 49,
};
Note I have no clue about jQuery & JavaScript so I don't even know if this is possible lol.
I hope you understand what I'm after and thanks in advance for any help