I have an opencart site developed for a client and 99% works fine except one annoying bug which is driving my client nuts, if a customer adds a product to the cart, it doesn't send the product option e.g. colour. and this then doesn't appear on the order in the admin, and my client has to ring the customer to get the order details.
My first thought was a server issue (max_vars etc) but this isn't the issue, I added another theme and it works fine.
I have checked my code and it's identical to the default theme (which works fine) and the only errors in the OC errors.txt is a category_id which shouldn't affect the cart system.
The website is http://goo.gl/2naK6n if you go to cycle and select the 3rd item in the top row.
Any help would be appreciated
Lets see i can not seem to find the exact error, and it really is a hustle to check the whole code so i will make a suggestion hoping it will fix it :), you should try and change the ajax code in the $('#button-cart').bind('click', function() { by replacing:
data: $('input[type=\'text\'], input[type=\'hidden\'], input[type=radio]:checked, input[type=checkbox]:checked, select, textarea'),
with
data: $('.product-info input[type=\'text\'], .product-info input[type=\'hidden\'], .product-info input[type=\'radio\']:checked, .product-info input[type=\'checkbox\']:checked, .product-info select, .product-info textarea'),
with this approach you specify in more accurate way the relation between products and options,
hope it solves your problem.
Related
I need to do a webpage to finish my uni, and im about 90% done with it, however, im struggling with getting custom Iterators and Charts to work.
Im trying to use Recharts, but i have no idea on how to make it gather the info i want (I need it to get the number of users registered and the number of vaccines they took), but all i see on the documentation is ready results, im not sure if ChartJS will make it any better, and even if it does, im confused on how custom iterators work since i took my "Analytics" one from another StackOverflow question, however that's the least of my worries, since this seems to be simplier than getting the ACTUAL charts to work.
Help would be appreciated since i have 2 weeks to deliver it and im stuck on that, and its CRUCIAL i get that to work.
Oh yes, im also very bad at Javascript so every info is welcome.
EDIT:Forgot to say i've looked around but lots of them are for simplier and static stuff instead of database counts or stuff like that.
Welcome to SO.
1) Recharts wants an array that it needs to iterate over and display. So what I usually do is make the Chart Component a child of a List component.
2) I use the Filter on the List page to select different chart components when the user selects different options from the dropdown (in case your analytics page needs to show different charts from the same page)
^^this is a bit tricky for peeps new to JS but is quite straightforward if you want to get into it.
3) For you i think the best bet will be that you make different List components and resources for each page and just display different charts on their own page.
export const AnalyticsList = (props) => {
return (
<List title="Analytics" {...props} perPage={20} sort={{ field: 'id', order: 'ASC' }}>
<Analytics />
</List>
)
}
here is how the Analytics Component is
import React from 'react';
import {BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, Legend} from 'recharts';
export const Analytics = (props) => {
return (
<BarChart width={800} height={400} data={Object.values(props.data)} margin={{top: 5, right: 30, left: 20, bottom: 5}}>
<XAxis dataKey="name"/>
<YAxis dataKey="charLimit" />
<CartesianGrid strokeDasharray="3 3"/>
<Tooltip/>
<Legend />
<Bar dataKey="charLimit" fill="#82ca9d" />
</BarChart>
);
}
Hope this helps.
I have that action_item on my admin page:
action_item :only => :index do
link_to I18n.t('admin.dem_ref_nvl_etb'), :action => 'whatever'
end
I'd like to know how I could display a pop-up window by clicking that link above, pretty much just like batch_action does when you use it with a "form" option (I don't need such an action here, it's just a basic link).
Any hint ?
Thanks a million for reading and helping!
Building on Hugues's answer, here's a more fleshed-out example that I managed to cobble together with my very meager javascript skills:
In app/assets/javascripts/active_admin.js:
//= require active_admin/base
$(document).on('ready page:load turbolinks:load', function() {
$('a.lextest').click(function(e) {
e.stopPropagation(); // prevent Rails UJS click event
e.preventDefault();
ActiveAdmin.modal_dialog("Send email to: ", {emails: 'text'}, function(inputs) {alert (inputs.emails)})
})
})
Note that I don't use the default active_admin.js.coffee because I dislike coffeescript -- just a personal preference. This code adds an onClick event handler to all links with class lextest. Now you can create such a link with a link_to:
link_to('Modal', '#', class: 'lextest')
I cobbled this all together from the way batch_action is implemented.
I found out your answer to your question. I won't go into much details as I suppose you know your Javascript, but this could be expand further.
ActiveAdmin come with a modal dialog javascript library. It is quite crude, but can get the job done. You can read about its existance on this documentation page:
http://activeadmin.info/docs/9-batch-actions.html
toward the 3/4 down at the end of the Batch Action form section.
For the exact code check github:
https://github.com/activeadmin/activeadmin/blob/master/app/assets/javascripts/active_admin/lib/modal_dialog.js.coffee
And this is a very basic example you can copy paste in a javascript console to check the effect.
ActiveAdmin.modal_dialog("Send email to: ", {emails: 'text'}, function(inputs) {alert (inputs.emails)})
As long as your good with your Javascript skills, you should be on track.
Chosen is working great for me but I cannot figure out how to get my acceptance test to send in the value on the form submit.
Handlebars template:
<form>
{{#ember-chosen value=country}}
{{#each countries as |country|}}
<option value={{country}}>{{country}}</option>
{{/each}}
{{/ember-chosen}}
{{#link-to 'countries.show' (query-params country=country) tagName='button' type='submit' replace=true class="submit__button"}}Search{{/link-to}}
</form>
Acceptance test:
test 'Searching for a country', (assert) ->
visit '/search'
find('.chosen-select').val('USA')
find('.chosen-select').trigger('chosen:updated')
click('.submit__button')
andThen ->
assert.equal find(".chosen-select :selected").text(), "USA"
This fails because on submit country is not even passed in as a query param, but only in the test.
The same thing happens if I do it in the console. If I open my console and do:
$('.chosen-select').val('USA')
$('.chosen-select').trigger('chosen:updated')
then the selection updates before my eyes! But then clicking submit produces the same results as the test, that is, the country is not passed into the query-params.
Clicking "USA" from the dropdown however, then clicking submit, works perfectly.
UPDATE
Chad Carbert's response below gave me the answer. Here are the specific results:
$('.chosen-select').val('USA')
$('.chosen-select').trigger('chosen:updated')
updates the DOM only. Not the data-bindings with Ember.
$('.chosen-select').trigger('change', {'selected': 'USA'})
updates the data-bindings (which is what I really need), not the DOM.
Since this is for my acceptance tests only and I don't need to see the DOM change, my test now looks like this:
test 'Searching for a country', (assert) ->
visit '/search'
find('.chosen-select').trigger('change', {'selected': 'USA'})
click('.submit__button')
andThen ->
assert.equal find(".chosen-select :selected").text(), "USA"
Which works like a charm! If you wanted to though, there would be no harm in doing all three:
test 'Searching for a country', (assert) ->
visit '/search'
find('.chosen-select').val('USA')
find('.chosen-select').trigger('chosen:updated')
find('.chosen-select').trigger('change', {'selected': 'USA'})
click('.submit__button')
andThen ->
assert.equal find(".chosen-select :selected").text(), "USA"
Thank you Chad!
It looks like this might be an issue with the way that this component wraps the jQuery library. Looking at the documentation for chosen:
Updating Chosen Dynamically
If you need to update the options in your select field and want Chosen to pick up the changes, you'll need to trigger the "chosen:updated" event on the field. Chosen will re-build itself based on the updated content.
via chosen docs
However, it doesn't look like the ember component is wrapping that event in any way. It also looks like the chosen:update is updating the chosen UI implementation, but not the data binding within Ember. This would be in a case where you've after the fact added options to the select, and want these reflected ('rebuilt') on the screen.
Looking at the code behind this component and how it's wrapping the chosen library, it appears that this component is only capturing the change event. So try doing a trigger on a change event and that should have things update within ember, and its data binding.
Or try triggering the change the way it's mentioned on the Chosen docs:
Form Field Change**
When working with form fields, you often want to perform some behavior after a value has been selected or deselected. Whenever a user selects a field in Chosen, it triggers a "change" event* on the original form field. That let's you do something like this:
$("#form_field").chosen().change( … );
If that doesn't work, if you're able to provide a codepen I will take a look closer, thanks!
What I am trying to achieve is to find a way of displaying a wiki page content in a floating iFrame ( and of course keep the styling ) for a tool that I am developing for our employees. Right now the tool I made is using jQuery dialog box to display a specific document / pdf, For compatibility and usability purposes I would really like to upgrade that so it uses a wiki page instead of documents / PDFs.The problem that I am facing is that there is no really direct link to the content of a Sharepoint wiki page instead the only available direct link is the one to the page all together with all the navigation menus, option panel, user panel etc. I want to avoid using javascrip to strip away these elements. Instead I am simply trying to find out if sharepoint 2013 has some more elegant way of providing the content such as: Web service or javascript SP API.
My ideas so far:
REST Url to give the content back? I know for sure it works for lists and libraries but I couldn't find anything in the REST API About wiki page content
SP.js ? Couldn't find anything about that either
Anyways, it could be possible that I have overlooked things, or probably haven't searched hard enough. However, any help is very very welcome. If you don't know about a concrete solution I would be very happy with nice suggestions too :)
If there is nothing out of the box I will have to get to my backup plan of a jQuery solution to get the page and strip off all unnecessary content and keep the styling.
I believe you are on the right track with REST API, in Enterprise Wiki Page the content is stored in PublishingPageContent property.
The following example demonstrates how to retrieve Enterprise Wiki Page content:
var getWikiPageContent = function (webUrl,itemId,result) {
var listTitle = "Pages";
var url = webUrl + "/_api/web/lists/GetByTitle('" + listTitle + "')/items(" + itemId + ")/PublishingPageContent";
$.getJSON(url,function( data ) {
result(data.value);
});
}
Usage
getWikiPageContent('https://contoso.sharepoint.com/',1,function(pageContent){
console.log(pageContent);
});
And something for those of you who like to have more than one different examples:
var inner_content;
var page_title = "home";
$.ajax({
url: "https://mysharepoint.sharepoint.com/MyEnterpriseWikiSite/_api/web/Lists/getbytitle('Pages')/items?$filter=Title eq '" + page_title +"'",
type: "GET",
headers: {
"ACCEPT": "application/json;odata=verbose"
},
success: function (data) {
if (data.d.results[0]) {
inner_content = data.d.results[0].PublishingPageContent;
}
},
error: function(){ //Show Error here }
});
That's what did the job for me.
This example fetches the inner content of an Enterprise wiki page by Title( make sure you are not using the Name of the page, although Title and Name can be given the same string value, they are different fields in sharepoint 2013 )
I'm trying to simply display the inventory count (the number displayed in the spree admin as "count on hand") in the front-end of my app. I'd like to display it on the product page to show how many of a product is left available...i'm still getting familiar with Spree...can I just do this through the front-end via deface changes???
I'm using Spree 2-1-stable...so far i've tried to replace the unordered list in the _taxons partial (spree / frontend / app / views / spree / products / _taxons.html.erb) with the count on hand using the following deface override...but i think I may be way off base.
Deface::Override.new(:virtual_path => 'spree/products/_taxons',
:replace => "ul#similar_items_by_taxon",
:text => "<%= product.total_on_hand %>",
:name => "product_profile_changes",)
(A previous stackO posting below had said to call total_on_hand, but that doesn't seem to be working either...)
Show all spree ecommerce products together with their count-on-hand displayed
My current code throws the following error:
SystemStackError in Spree::ProductsController#show
stack level too deep
Rails.root: /Users/user/Documents/spree_flash_sales/spec/dummy
If i have to add something to the controller or model, which specific files would it go in and what would the code look like? Any help would be much appreciated...thanks,
Well i guess i'll leave my own answer...another boneheaded mistake.
I just left out the # in the text line. i.e,
:text => "<%= #product.total_on_hand %>",
(I need to take some courses on debugging)