jimiayler
Forum Replies Created
-
Forum: Plugins
In reply to: [SEOPress - AI SEO Plugin & On-site SEO] Sitemaps.xml errorHi, thanks for your prompt response. Sorry to say, however, that adding this line of code to my theme’s functions.php file:
add_filter('seopress_sitemaps_single_shortcodes', '__return_false');has resulted in no change to the result when I go to (after emptying my cache and hard reloading the page in my browser) https://vescomdecor.com/sitemaps.xml/ . Note that I get a slightly different error when I try to load the sitemap in Firefox (the initial error above is from Chrome):
XML Parsing Error: XML or text declaration not at start of entity
Location: https://vescomdecor.com/sitemaps.xml/
Line Number 2, Column 1:
<?xml version=”1.0″ encoding=”UTF-8″?><?xml-stylesheet type=”text/xsl” href=”https://vescomdecor.com/sitemaps_xsl.xsl”?>
^Forum: Plugins
In reply to: [Contact Form 7] Add Other HTML Values to Contact Form EmailThe lack of response to this has been disappointing and the disappointments with CF7 continue. The solution I was able to discover, provided by a senior developer, was completely outside of the events made available by Contact Form 7, because they all fire after submitting the form. I had to add this piece of code to the end of the theme.js file located at the WordPress theme we’re using: /wp-content/themes/vg-ebuilder/assets/js/theme.js. This captures the submit before the form is serialized for the Ajax call and parses the table into new arrays to be pushed to the email body:
jQuery(".wpcf7-form").on('submit', function(event){ var carttable = document.getElementById("carttable"); var cartHTML = document.getElementById("ShoppingCart"); if (!cartHTML) { cartHTML = document.createElement("INPUT"); cartHTML.setAttribute("type", "hidden"); cartHTML.id = "ShoppingCart"; cartHTML.name = "ShoppingCart"; } var csv = []; var rows = carttable.querySelectorAll("table tr"); var header = []; //Build the header if (rows.length > 0) { var headCols = rows[0].querySelectorAll("td, th"); for (var t = 1; t < headCols.length - 2; t++) { header.push(headCols[t].innerText); } } //Retrieve the data for (var i = 1; i < rows.length - 1; i++) { var row = [], cols = rows[i].querySelectorAll("td, th"); for (var j = 1; j < cols.length - 2; j++) { if (jQuery(cols[j]).find("INPUT").length > 0) { row.push(header[j - 1] + ": " + jQuery(cols[j]).find("INPUT").val()); } else row.push(header[j - 1] + ": " + cols[j].innerText); } csv.push(row.join("\n")); csv.push("\n"); csv.push("-------------------------------------------------------------"); csv.push("\n"); } cartHTML.value = csv.join("\n"); document.getElementsByClassName("wpcf7-form")[0].appendChild(cartHTML); });You then need to update the Mail portion of the form in the Contact Form 7 settings to include a new variable called ShoppingCart.
It’s a shame that so much effort has to be made for such simple DOM retrieval/injection. Since CF7 has deprecated Javascript inclusion before submitting in favor of DOM event listeners, it would be nice if you could allow some customization of an email prior to sending one from a form submit.
Forum: Plugins
In reply to: [Contact Form 7] Add Other HTML Values to Contact Form EmailI have found the way according to the documentation to add the table itself to the form, but not how to include the table in the email that is eventually sent from it. Assuming the table has an ID of “carttable,” the table can be appended to the form on submit thusly:
document.addEventListener( 'wpcf7submit', function( event ) { var carttable = document.getElementById("carttable"); document.getElementsByClassName("wpcf7-form")[0].appendChild(carttable); }, false );But this doesn’t tell me what I need to know how to have that table added as an HTML element to the email Contact Forms 7 would ultimately send on submitting the form. I hope someone can respond to this question soon.