Prestashop how to make modification on Add and Minus button in shopping cart - prestashop

who knows what file controls the function for add and minus button in the shopping cart? I want to change the qty that is added or minus after any buttons is clicked.
this is the code for the ADD button
<a rel="nofollow" class="" id="" href="{$link->getPageLink('cart', true, NULL, "add=1&id_product={$product.id_product|intval}&ipa={$product.id_product_attribute|intval}&id_address_delivery={$product.id_address_delivery|intval}&token={$token_cart}")|escape:'html':'UTF-8'}" title="{l s='Add' mod='advancedcheckout'}"><span><i class="fa fa-plus"></i></span></a>
Changing add=1 is not making any changes. So At start I thought it was a JS or AJAX file, but the button continues working even after I deleted all classes and ID. So I think all this trick is made by the code in href=""
But where I can make the changes for the qty added? Who knows?

If I good understand. You should look at those file:
themes/defaylt-theme/js/product.js: line 424
themes/defaylt-theme/js/product.js: line 408

You have to check the
cart-summary.js
in your theme/js/ folder. This will contain the + and the - button events
function upQuantity
function downQuantity

Related

How to populate drop down when it is built using an input tag using java and selenium

I have a drop down built with extJS.
<input id="combo-1786-inputEl" data-ref="inputEl" type="text" size="1" name="Query Category" placeholder="Select query category" role="combobox" aria-hidden="false" aria-disabled="false" aria-readonly="false" aria-invalid="true" aria-required="true" aria-haspopup="true" aria-expanded="false" aria-autocomplete="list" class="x-form-field x-form-required-field x-form-text x-form-text-default x-form-invalid-field x-form-invalid-field-default x-form-empty-field x-form-empty-field-default" autocomplete="off" data-componentid="combo-1786" data-errorqtip="<ul class="x-list-plain"><li>This field is required</li></ul>" aria-describedby="combo-1786-ariaErrorEl">
As we can see the tag used is 'input' and not 'select'.
So when I looked up about how to populate it, most answers were made under the assumption that it was created using a 'select' tag and it did not work.
Also the drop downitems are fetched from DB only when I click on the arrow on the dropdown:
So as a result of this, the drop down items cant be found on the page source.
Can someone one please suggest how to populate such downs using the best practice?
P.S-I do have a workaround, but its not at all good code practice and not at all generic:
driver.findElement(By.xpath("//*[#id='combo-1731-trigger-picker']")).click();//clicking on the arrow key of the drop down.
//Once the drop down item comes, I am trying to replicate pressing the keyboard arrow key,by sending down arrow key to the drop down item(web element)
//This works for me because I know the extact position of my drop down item in the drop down item list.It will stop working if the postion of the drop item changes
//so below loop just presses the down arrow key required number of times.
for(int i=0;i<5;i++){
driver.findElement(By.xpath("//*[#id='combo-1731-inputEl']")).sendKeys(Keys.ARROW_DOWN);
}
driver.findElement(By.xpath("//*[#id='combo-1731-inputEl']")).sendKeys(Keys.ENTER);
If you read the comments mentioned along with the above code, then you can understand how fragile the logic is.
Please help.
You are trying to click/ select the item in the drop down correct?
Do the drop down items have unique id's? If so you should be able to just pass it the specific xpath id.
I personally use Css to find elements, in that case it would be
driver.find_element(By.CSS_SELECTOR,'#combo-1731-trigger-picker').click()
driver.find_element(By.CSS_SELECTOR, '#combo-1731-inputEl > nth:child(x)').click()
where x = the count of your drop down item.
or if they have unique id's then use
driver.find_element(By.CSS_SELECTOR, '#theUniqueIdGoesHere').click()
I wrote a whole weeks worth of tests, using xpath selectors, it was painful day to day running the test and watching it fail. Going back and changing everything to Css selectors has saved me many head aches since I started writing Auto tests.
Edit: you could try the following,
driver.findElement(By.linkText("Your Links Text Here")).click();
This will only work if each links text is unique as well, if not it will select the first one it finds.
If these work for you would you mind accepting my answer?

Vue.js: How to initially check one of the radio button?

I am using the following code to generate radio buttons in my template.
<template v-for="(property,index) in propertiesList">
<input type="radio" :value="index" v-model="picked2"
:checked="property.checked">{{property.address}}<br>
</template>
property.checked has value of checked for one of the rows, and is null for rest of rows. I want to show the corresponding row (with property.checked = 'checked') as checked when the page is rendered. However, all rows appear as unchecked. Could someone please advise how to fix the issue? Thanks.
#Bret has provided the answer in the comment (to my question).

Prestashop: how to add fields to the order summary page

I'm working with Prestashop 1.6 and I need to add a checkbox and text field in the order summary page, as shown below.
I'm lost on which hooks to use to do so. These fields should be also shown in the invoice. For the hook of the invoice I believe it is the DisplayPDFInvoice hook, but for the order summary (display and get information) I don't know which hooks to use.
Can you give me some tips? Thanks for any help
You can use hook hookDisplayBeforeShoppingCartBlock to render any content on cart summary page. Don't forget to register this hook to your module.
I have tried using the same and got the results as below:
Code:
public function hookDisplayBeforeShoppingCartBlock()
{
return '<div>Text Area : </div><textarea rows="3" cols="30">This is a text area rendered from hookDisplayBeforeShoppingCartBlock</textarea><br><br><input type="checkbox" name="vehicle" value="Bike">checkbox 1<br><input type="checkbox" name="vehicle" value="Car">checkbox 2';
}
The above code is used just to show an example, you can render any template file from there. As you can see that this hook renders content above cart block so you can use javascript to move it below cart block.

How to get the xpath for the span button

I am new to selenium IDE and trying to get the target in the right order.
I have tried many combination to get the right element when there is span for the button. I need to get the xpath for the "Read More" button.Can someone please advise how the target in the IDE should be.
Here is the code:
<div class="is_centered l_bottom_pad">
<a class="btn_teal_outline has_arrow" href="https://test.com/jobs/view.php?id=8">
<span>Read More</span>
</a>
</div>
In some browsers (I think it was mainly MSIE) it is necessary to address the <a> element, not its child <span> in order to click a button or link. So you should adress:
//a[span[text()='Read More']]
Or you go directly for LinkText ("Read More") instead of XPath!
Targeting for span button is very simple. Just see what is unique attribute in that element.
I feel the button text itself is unique.Try this one
xpath=.//span[text()='Read More']

prestashop free shipping issue

I just upgraded firstly manually but later on by 1-click Upgradev1.0.13 to 1.5.4 version. I got a big problem on shopping cart with the shipping fees.
The cart located on homepage top left was solve not to show "FREE SHIPPING" from the previous code in this forum.
But once I checked on the shopping cart inside after I select and press "Update Carrier List" button and
press "Update Cart" button, the shipping fees is not updated but show as "FREE SHIPPING".
Could anyone suggest me solution about this? Thank you very much. I very much appreciate it.
My demo website is http://store.relishthai.com/.
You can try to add item by selecting the "TEA" tag and add one item to the cart and see the "FREE SHIPPING" problem.
I have had a very similar issue. The problem is that there is a Javascript file that updates the value to "FREE SHIPPING" if the value(shipping price) is equal to 0.00. I am using a different version, so I can't exactly point you to the file, but you can definitely solve this in three minutes. (Check order-opc.js in your theme/js folder)
View source of the web page and see what .js files are included. Search "FREE SHIPPING" in Javascript files (such as cart.js) and see which one is the culprit. Then go on FTP and change it to 0.00. I prefer "Free!" by the way ;)
EDIT: It seems like I misread your Q.
I tried pressing "Update carrier list" and then "Update cart", but I do not see the shipping fees as "Free shipping." Instead, I see 8 dollars.
Thanks again. Previously before your answer the $0.00 appeared in the top left cart on the page but later on after your comments I double checked things and deleted unused zone (no fees in there). And I tried to put the real shipping fees for all weight ranges. Now, the old problems has been solved but the shipping fees with weight ranges (in small ranges) still exits. I'll try to figure things out.
Many Thanks!!
Open the file /themes/xxx/modules/blockcart/blockcart.tpl
and remove this block of code (or comment):
<div class="layer_cart_row">
<strong class="dark">
{l s='Total shipping' mod='blockcart'} {if $display_tax_label}{if $priceDisplay == 1}{l s='(tax excl.)' mod='blockcart'}{else}{l s='(tax incl.)' mod='blockcart'}{/if}{/if}
</strong>
<span class="ajax_cart_shipping_cost">
{if $shipping_cost_float == 0}
{l s='Free shipping!' mod='blockcart'}
{else}
{$shipping_cost}
{/if}
</span>
</div>