Add specific price Prestashop - javascript

In the product page I want to create a special div that display itselft with Jquery, in that page the client will find different options that he could add like an accesory, the question is: How I can add a specific price adding up : base price + specific price + combination price.
I was trying to modify product.js but it didn't change anything, I'm not expert in prestashop core, Then as many information you could let me will be very gratefull.
Thank you.

On the product page there are various JS variable for price and combinations are already there.
So you can simply create a module with a hook (hookDisplayLeftColumnProduct, hookDisplayRightColumnProduct etc.) on product page to render your JS code on the product page and through that code you can achieve what you want (also using the price JS variables on product page).
public function hookDisplayLeftColumnProduct()
{
// Render Your tpl here
}

Related

How to make an input read off a value in Javascript

I'm making a website with products and a cart system. Basically, all the products' prices are displayed using an id of "price" in an tag, with the price being the text shown to the user. When adding an item to the cart, the code looks for the id="price" inside the tag and subsequently adds the price given in that line.
For example, a normal price line reads <h2 id="price">$8.99</h2> and the function picking it up uses var price = document.getElementById('price') to fetch the information. This works great.
HOWEVER
I am adding a new product with multiple options, and depending on the option the price updates. I have a working system in place to show the viewer the updated price based on their option, but this uses an tag because it is displayed through Javascript and needs to be updated.
The line that displays the price to the viewer looks like this:
<input type="text" id="price" value="24.99" /readonly="">
I'm pretty sure that because the price is displayed inside the tag, inside a value, the cart js doesn't know to look for it and therefore will not return a price.
Is there a way I can make a document.getElementById('price') fetch the value shown inside the <input>?
P.S. I have never really formally learned JS so I have no idea what I'm doing... I've mostly relied on Stack Overflow. Sorry if I seem like an idiot.

How can I dynamically control a Region Display Selector in Oracle APEX?

I'm hoping to select a particular Region to highlight on the page load based on the link the user follows to get to that page. This is a drill-down report with multiple options, so the goal is to have all options available but focus on the one the user selected to reduce the number of times a user has to navigate to/from the base report to the drill-downs.
Currently, I'm trying to implement this solution https://svenweller.wordpress.com.../, further explained in an Oracle Community discussion here: https://community.oracle.com/..., but it is not working for me.
What I have now is similar to what is shown in those examples, and for now I'm just trying to link to a static Region Display Selector (RDS) tab (the goal will be to have the selected Region be dynamic based on which link is clicked in the feeder page, but I'm clearly not there yet).
I have a Dynamic Action set to fire on Page Load event, and a True action that executes JavaScript code and uses the JavaScript in the example (both with and without the Timeout function suggested in the Oracle thread). I have set Static IDs for the RDS and Region, but when I load the page the RDS still defaults to Show All (or the first region if Show All is off).
Can someone help me understand what I'm doing wrong?
Thanks.
let sesStorage = apex.storage.getScopedSessionStorage({
useAppId:true,
usePageId:true});
setTimeout(sesStorage.setItem( "tabs.activeTab", "#R3" ) { apex.region("tabs").widget().aTabs("getTabs")["#R3"].makeActive();}, 300);
\\version without setTimeout
let sesStorage = apex.storage.getScopedSessionStorage({
useAppId:true,
usePageId:true});
sesStorage.setItem( "tabs.activeTab", "#R3" );
I have done something like this in the past. Create a hidden variable on the page P1_TEST, make sure to set the value not to be protected.
You will need to set the value of that variable when the link is clicked.
Then you need to add static IDs TAB1, TAB2 etc. to the tabs of you region display selector.
Then add a DA on Page Load:
if (apex.item("P1_TEST").getValue() === "Value1"){
$(".apex-rds [href='#TAB1']").trigger('click');
} else if (apex.item("P1_TEST").getValue() === "Value2"){
$(".apex-rds [href='#TAB2']").trigger('click');
}

Shopify: Unable to retrieve product tags on Thank_You page

I am developing a Shopify app that need to retrieve current product tags which is ordered/purchased on thank you page. I can retrieve
line_items
but
line_items
don't have product tags so is there any solution to retrieve the product tags for the current product that is orders. I want to trigger a console function along with product tags.
Any solution via Ajax call or etc?
Any solution?
You would want to make a GET request for that product, at which point you can retrieve the tags for it.
GET /admin/products/#{id}.json?fields=tags
Via JS on the frontend, you can just query product-handle.js
Example:
jQuery.getJSON('/products/a-b-c-d-e.js', function(product) {
console.log('The tags for this product are ' + product.tags);
} );
Result:
The tags for this product are test1,test2

displaying results(subproject) as sublist and I want to filter the results based on selected project from drop down

I created one form, in that 2 sections one is header(parent) and another one is child. In header section i created one field like project(Drop down) like netsuite, SFDC etc and in child section i created one more field like subproject. When I am selecting any project according into that subproject name should be display . Please any one can answer me.
Have you created form with Suitelet or from Custom Record Form ? [ Please elaborate ]
If you have created with Suitelet it's more easy to do than the Netsuite's Standardized custom form..
First create a sublist using form.addSublist('custpage_subproj_lst','list','Sub Project List',null); give type as list..
Add fields to list as many as columns required....make sure the field type from the subproject must match with column type...
Now Create client script but don't deploy it on anything...
Get that client scripts id Ex. "customscript_client_script" and add the following immediately after creating form like...form.addScript("customscript_client_script");
Now once you added client script to that form...create the Field Change function and add it in client script...
Now in Client Scripts Field Change function, check for Project field change and remove all child level lines....
Now Create a search on subproject by filtering the project...and get the results and set line level values from that save search...

How to force "selected" attribute for variation options in Woocommerce?

I'm developing a Woocommerce theme for one of my clients.
For this project, I needed to clone the cart form (on product pages) in order to display it in another place on the page.
I managed to do this with this piece of code :
$(document).on( 'found_variation', 'form.cart', function( event, variation ) { // found_variation // woocommerce_variation_select_change
$('.fixed-price-right').empty();
$(this).clone().appendTo( '.fixed-price-right' ).each(function() {
$('.product-fixi').scrollToFixed();
});
});
First, on each variation changes, I empty the div in which the form clone will be displayed.
Then, I clone it and made the container div fixed.
The problem is that I get everything except the selected variation value.
Actually, the default selected value got this attribute : selected="selected". But this attribute is not applied to other options.
You can see a living example here: http://www.pro4mance.com.au/product/produrance-energy-gels-2/
If I submit from the cloned form, the product is added but without option.
The weird thing is that if I add manually (from web console) this attr in the right option of the cloned form and then add the product to the cart, the product is added with all the good options.
I don't really know how to force the adding of selected="selected" on each change. Can someone please help me to manage it?
Thanks everyone!
For everyone who need to force the adding of the "selected" attribute on Woocommerce option variables, here's how I did it (using jQuery):
$('form.cart').on( 'change', '.variations select', function( event ) {
$val=$(this).val();
$(this).children('option').each(function(){
$childVal = $(this).val();
if ( $childVal == $val ) {
$(this).attr('selected', 'selected');
} else {
$(this).removeAttr('selected');
}
});
});
Feel free to improve it (that's maybe not the best way to do it).
I think you are going to have to look at the file cart.php within the WooCommerce templates folder. Use that to create your own custom cart file. Just run the loop a second time to get EXACTLY what you want, delivered directly from the server. ref: WordPress -- "the Loop" The actual line of code you are interested in is foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { For the WooCommerce cart, that's the top of the "loop". Add that line again, with your own customization to match your desired second copy of the contents of the shopping cart...
I'd recommend leaving jQuery out of it...
You obviously don't want to append directly within the WooCommerce package (in case of future updates)... (updates here!)
Wow, that seems very easy...
WooCommerce (and almost all add-ons) provides a templating system.
This means that every element displayed on a WooCommerce page can be
overridden.
This system’s advantage is that you can modify the display of an
element without editing WooCommerce core files (which is absolutely
NOT recommended, if you do so, all your modifications will be lost at
the next WooCommerce update, so just don’t do it). All templates are
located in a woocommerce/templates folder. As explained in our
documentation, all you have to do is to create a woocommerce folder
within your theme’s directory, and in this folder duplicate the files
you’d like to override. Please note that we strongly recommend using a
child theme in order not to lose any modifications during your theme
update.

Categories