I have a serious problem here with the Conversion tracking code of Google. I've searched everywhere to no avail. I need to run this script on my Success page of OpenCart version 1.5.1.3.
<!-- Google Code for Sales Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 994251914;
var google_conversion_language = "en";
var google_conversion_format = "2";
var google_conversion_color = "ffffff";
var google_conversion_label = "ifQwCN7LqQQQiqmM2gM";
var google_conversion_value = Total_Cost_Variable <--HERE IS THE PROBLEM
/* ]]> */
The problem is that I can't find the variable that shows the Total Cost of the purchased items in the Success page.
Please, any help would be really appreciated!
This isn't something that is readily available. You will need to extract the total cost from the order in the checkout/success.php controller file, then add it to the data to be passed to the view. This is because the success controller clears the cart before the success page, making the values non existent from that point forwards
Related
I've read the tutorials to log into a website prior to scraping it, but it just ain't workin'. I constructed a HttpIdentity object, added it to the Identities collection, and processed the request, but the page returned to scrape was still the login page. There isn't a lot about this on their website and documentation. Here's my code for that:
var identity = new HttpIdentity
{
UseCookies = true,
NetworkUsername = _username,
NetworkPassword = _password
};
Identities.Add(identity);
Request(_uri, Parse, identity);
In the Parse method I get a Response object returned with a Status Code of 200, and the "WasSuccessful" property of Response is "true". It seems that I should be redirected to the page I was trying to access, but I'm just getting the login html.
Is there something I'm missing?
I wasn't able to find a solution using the Iron Web Scraper, but I was able to do it with ScrapySharp, which is a free utility, so it worked out. ScrapySharp is able to mimic a browser to a degree, so navigation and submitting forms is pretty easy.
var browser = new ScrapingBrowser();
var homepage = browser.NavigateToPage(_Uri); // login Uri
var form = homepage.FindForm("login"); // get form by name
form.Method = HttpVerb.Post;
form["username"] = "my_username"; // get form fields by id
form["password"] = "my_password";
var resultPage = form.Submit(); // login
var loggedInPage = browser.NavigateToPage(new Uri("https://path.to.target.page"));
And that's it. I'm not sure what the problem was with Iron Web Scraper. Maybe some ajax on the login page. In any case, this code is working for me now.
I want to customise the product template, but not for all cases hence I am creating a new template layout file.
I have tried to do this two ways, however both don't work and encounter the same issue with %%GLOBAL variables not working.
Using Product.html as a base, I created _Product.html and changed %%Panel.ProductDetails%% to my custom ProductDetails file %%Panel._ProductDetails%%, which I haven't customised at all at this stage. I then change a test product to use that template. When viewing the product, console errors ar produced and the page doesn't show properly. The cause of the first console error is a syntax error where script variables are being set to a %%GLOBAL variable. Looking at the page source, this is the result:
<script type="text/javascript">//<![CDATA[
var ThumbURLs = new Array();
var ProductImageDescriptions = new Array();
var CurrentProdThumbImage = ;
var ShowVariationThumb =false;
var ProductThumbWidth = ;
var ProductThumbHeight = ;
var ProductMaxZoomWidth = ;
var ProductMaxZoomHeight = ;
var ProductTinyWidth = ;
var ProductTinyHeight = ;
where the template is
<script type="text/javascript">//<![CDATA[
var ThumbURLs = new Array();
var ProductImageDescriptions = new Array();
var CurrentProdThumbImage = %%GLOBAL_CurrentProdThumbImage%%;
var ShowVariationThumb =false;
var ProductThumbWidth = %%GLOBAL_ProductThumbWidth%%;
var ProductThumbHeight = %%GLOBAL_ProductThumbHeight%%;
var ProductMaxZoomWidth = %%GLOBAL_ProductMaxZoomWidth%%;
var ProductMaxZoomHeight = %%GLOBAL_ProductMaxZoomHeight%%;
var ProductTinyWidth = %%GLOBAL_ProductMaxTinyWidth%%;
var ProductTinyHeight = %%GLOBAL_ProductMaxTinyHeight%%;
The weird part is that there are %%global variables just above it that work fine.
<script type="text/javascript" src="%%GLOBAL_CdnAppPath%%/javascript/jquery/plugins/jCarousel/jCarousel.js?%%GLOBAL_JSCacheToken%%"></script>
gets correctly gets interpreted as
<script type="text/javascript" src="http://cdn3.bigcommerce.com/r-8a870c678fbffbf4184af752aed70da3f3454036/javascript/jquery/plugins/jCarousel/jCarousel.js?"></script>
The second way I tried was to include everything in the top level template. Instead of linking to %%Panel._ProductDetails%%, I inserted the contents of that panel into _Product.html, however this also encounters exactly the same issue.
Does anyone know why neither of these options work and how I can achieve what I want?
You have to call Panel.ProductDetails prior to using those variables.
Even if you are using a custom product details alternative panel you need to reference the standard one first. Then your global variables will work.
This is because GLOBALS in the BigCommerce system will only print a value where they have been permitted by the BigCommerce development team. This can be a pain, especially for the values you are after, and what you want to do makes perfect sense.
At this time however, I suggest you make it known to the developers you want this at http://ideas.bigcommerce.com.
I can't say whether this will change anytime soon as the main reason for the GLOBALS being banned in certain areas is for security, although the ones you are after are useful, and I don't see why they aren't enabled either. Who knows, the developers may surprise us.
I'm currently writing a site using Sitefinity CMS. Can someone please explain how to get the current dynamic content item from server side code on page_load?
I have written a user control to display a custom gallery of sliding images. There are multiple content types in my dynamic module. The user control will sit as part of the masterpage template rather than on every page. On each page load I would like to fetch the current dynamiccontent item that is associated with the page and examine whether it has a property with the name 'Gallery'. If so I would then extract the images and render them via the usercontrol.
Thanks,
Brian.
I'm assuming your images are related content. This gets every published content item of your type.
var dynamicModuleManager = DynamicModuleManager.GetManager();
var moduleType = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.YOURTYPEHERE");
var dcItems = dynamicModuleManager.GetDataItems(moduleType)
.Where(l => l.Status == ContentLifecycleStatus.Master);
foreach (var dcItem in dcItems)
{
//pass the dynamic content item to a model constructor or populate here, then
// get your image this way:
var image = dcItem.GetRelatedItems<Image>("Images").SingleOrDefault();
if (image != null)
{
ImageUrl = image.MediaUrl;
}
}
Due to some restrictions with a CMS I am developing for I cannot create the intended markup for a proper accordion with Bootstrap 3 on page load, however I can get it very close.
The issue I am having is that the initial
panel group id (accordion1), I cannot assign the proper data-parent="accordion1" to the data-toggle="collapse" element in the panel. I am attempting to rewrite the data-parent references to the proper accordion ID but it does not have an affect, it is like the collapse binding is already in place and I'm not sure how to get around it.
This is an example of my issue. (id's are the same on page load but I try to rewrite them with a script on dom-ready)
$(document).ready(function() {
$('.panel-group').each(function() {
var $t = $(this);
var id = "#" + $t.attr("id");
$t.find('[data-parent]').attr("data-parent", id);
});
});
This function fixes the markup as BS3 wants but the functionality is still broken.
http://plnkr.co/CTBekXVyzU0xjzlud2N1
I ended up figuring out that the error was my own. Multiple accordions is not an issue. Where I went wrong was in the markup. The error in my ways weas that the data-toggle="collapse" element's href="#collapse-0" for example was duplicated for both accordions. They must be unique. The CMS restriction still existed on the data-parent however. This caused me to redo my script (which does work now for multiple accordions)
$('.panel-group').each(function(){
//setup each panel group with individual id's appropriately
var $t = $(this);
var id = "#" + $t.attr('id');
var randomInt = $t.attr('id').split('_')[1]; //extract
$t.find('.panel').each(function(){
//set the proper collapsable targets for each
var $t = $(this);
var $dataParent = $t.find('[data-parent]');
var href = $dataParent.attr('href');
//set the collapse target
var $targetId = $dataParent.attr('href', injectRandom(href, randomInt));
var targetId = $targetId.attr('href').split('#')[1];
//set the random id's
$dataParent.attr('data-parent', id);
//set the collapse container
$dataParent.parents('.panel-heading:first').next().attr('id', targetId);
});
//open first pane
$t.find('[data-toggle]:first').trigger('click');
});
I will update the plunkr
I am struggling with modifying some code in Customer registration management module. Instant checkout is not working the way it should. When the Customer registration management module is disabled, the Instant Checkout is working fine, on submit and with no errors we go to the next step/screen. When Customer registration module is enabled, once we click on submit button under Instant checkout, we do not go to the next step/screen, instead we come back to the same screens, forms empty, and in url we have this: authentication?back=order.php%3Fstep%3D1
I managed to identify a piece a code which is preventing a customer from going to the following screen from Instant checkout form. It is the code in function hookCreateAccount($params)
function hookCreateAccount($params)
{
require_once (dirname(__FILE__).'/ApprovedCustomer.php');
global $cookie, $back;
$registration_code = pSQL(Tools::getValue('registration_code'));
if ($registration_code != '' AND $registration_code == $this->_registrationCode) {
$customer = $params['newCustomer'];
$customer->cleanGroups();
$customer->addGroups ($this->_defaultGroups);
}
$cookie->logged = $this->_isCustomerRegistredByDefault;
$cust = $params['newCustomer'];
$approval = new ApprovedCustomer($cust->id);
$approval->is_approved = $this->_isCustomerRegistredByDefault;
$approval->privilege_request = intval(Tools::getValue('privilege_request'),0);
$approval->privilege_message = pSQL(Tools::getValue('privilege_message'), '');;
if (! $approval->save())
Tools::D('Unable to save approval information');
if ($this->_sendAdminMail)
$this->sendMail('pending_registration', array('customer' => $cust, 'approval'=>$approval));
if (! $approval->is_approved) {
$back = 'modules/'.basename(__FILE__, '.php').'/messages.php?msg=noconnect&back=my-account.php';
$cookie->logged = 0;
$cookie->id_customer = 0;
}
elseif ($back == '')
$back = 'my-account.php';
}
Anybody has any ideas what in this code is causing this? any help would be really appreciated.
exactly what happens: once the user fill in Instant checkout form and clicks on submit, the form is redirected to the same page: ... /authentication?back=order.php%3Fstep%3D1
but it should go to: /order?step=2
the Instant Checkout form action:
<form action="{$link->getPageLink('authentication.php', true)}?back={$back}" method="post" id="new_account_form" class="std">
so, should I change the action part then? how does this work? could somebody point me to the right direction? any help would be really appreciated.
I suspect that the conflict occurs because by definition your customer isn't registering as part of the One Page Checkout functionality (I assume this is what you mean by Instant Checkout).
You could try refactoring the first block of code as:
global $cookie, $back;
$customer = $params['newCustomer'];
if ($customer->is_guest)
return;
require_once (dirname(__FILE__).'/ApprovedCustomer.php');
$registration_code = pSQL(Tools::getValue('registration_code'));
if ($registration_code != '' AND $registration_code == $this->_registrationCode) {
$customer->cleanGroups();
$customer->addGroups ($this->_defaultGroups);
}