Ik had een vraag over javascript i.c.m. wordpress. Ik heb een script dat ik moet installeren op mijn website, maar heb geen idee hoe dit moet aanpakken. Wie zou hiermee kunnen helpen, uiteraard tegen betaling. Groet Leon
[quote="- Ariën - op 02/03/2017 15:05:39"]
Een child-template zou toch ook kunnen?
Op zich wel maar waarom zou je een functionaliteit die los staat van je opmaak in een theme zetten? Dan kun je later niet meer van theme wisselen zonder die functionaliteit kwijt te raken...
[/quote]
Touché!
Ik heb de pagina en plugin aangemaakt. Dit is gelukt. Hoe kan ik nu op een pagina zorgen dat deze zichtbaar is. Het gaat er namelijk om de iframe zichtbaar gaat worden. Je kan met het script als het goed is een soort van iframe maken.
Ik heb mijn shop ID al goed gezet. Ik maak gebruik van Visual Composer en Elementor.
Parameters
The parameter shopId and platform should be present. You'll find your shopId in the user area of spreadshirt. The platform decided if you like to speak with the European (EU) or the North American (NA) platform.
var requiredParameter = {
// required parameter
shopId: 123456, // your own shopId
platform: "EU", // the spreadshirt platform: "EU", "NA"
};
To change the look and feel of the application you can use the following parameter. By default the iframe will use 100% of the width and 700px in height and attaches to the document.body.
var layoutParameter = {
// iframe size
width: "100%", // width in px or %
height: "700px", // height in px or %
// render target
target: document.getElementById("someDiv"),
shareUrlTemplate: "https://example.com/create#productId={PRODUCT_ID}&viewId={VIEW_ID}"
};
Deeplinks
All other parameters are optional and change the initialization of the application. E.g. you could deeplink a specific productType (iPhone: 776) or add an image to the product. The list of product types id, available appearances and designs you get from the API.
There is also the possibility to automatically parse the deeplinks form the query parameters of the URL by using the option parseDeeplinks: true.
var possibleParameter = {
// optional design deeplinks
designUrl: null, /* an URL to an image, it will be uploaded.
* **You agree that you will have the rights to use this image**
*/
designId: null, // the id of an exisitng design
designColor1: null, // the printColor Id for layer 1
designColor2: null, // layer 2
designColor3: null, // layer 3
designColorRgb1: null, // or if you like RGB codes for the following layers
designColorRgb2: null,
designColorRgb3: null,
// product relevant deeplinks
productId: null, // id of an existing product
appearanceId: null, // load the appearance (color) for the product type
sizeId: null, // preselect the product type size in combination with quantity
quantity: null, // speficies the quantity, used in combination with sizeId
viewId: null, // show this view of the product
// product type
productTypeId: null, // start with the product type - cannot be used in combination with productId
// text deeplinks, the won't work without deeplinking a productType || product || basketItem
tx1: null, // first line of text
tx2: null, // second line of text ...
tx3: null, // ... and guess, the third line
isExample: false, // a boolean flag indicating if the text configuration from tx1= deeplinks is removed or not
textColorRgb: null, // you can specify colors either as rgb value
textColor: null, // or as id of an print type
// independent
departmentId: null, // load this product type department
productTypeCategoryId: null, // or this product type category
// also independent, but for designs
designCategoryId: null, // open this designCategory
designSearch: null, // or perform a search for designs with the term
panel: null, // show the following panel first - "productTypes", "designs", "upload", "imageNetwork"
basketId: null // the id of the api basket to use
safeSearch: null // available values "strict" or "off". By default "off
Er wordt bij //render target verwezen naar een ID-element met de naam: someDiv, die ik maar voor het gemak even SpreadShirtShop noem. pas die regel even aan met die naam.
En maak eens dit aan in je templates:
<div id="SpreadShirtShop"> </div>
Dan zal er als het goed gaat iets spannends gerenderd worden.
Ik heb nog nooit met SpreadShirt gewerkt, dus ik hoop dat dit werkt of een stap in de goede richting is.
In theorie zou het ook zonder die div moeten lukken omdat hij standaard aan de <body> tag gekoppeld wordt.
Maar moet eerlijk zeggen dat ik niet zoveel verstand van javascript heb. Als ik de documentatie lees lijkt me dat hij het gewoon moet doen, maar dat het wel belangerijk is dat het platform (land) goed ingesteld wordt.