xml TS //选择附加产品的选项/属性。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了xml TS //选择附加产品的选项/属性。相关的知识,希望对你有一定的参考价值。

<mvt:comment> === Editable Attributes Content === </mvt:comment>
<head>
<mvt:if expr="NOT ISNULL l.settings:product:metafield:title">
	<title>&mvt:product:metafield:title;</title>         
<mvt:else>
	<title>&mvt:product:name;: &mvt:store:name;</title>
</mvt:if>
<link rel="stylesheet" type="text/css" href="/css/editable_attributes.css">
<mvt:item name="attributemachine" param="head" />
<mvt:item name="product_display_imagemachine" param="head" />
</head>
<body id="editable_attributes">
	<mvt:if expr="g.secure EQ 1">
		<form method="post" action="&mvte:global:secure_sessionurl;Screen=BASK" name="add" id="purchase-form">
	<mvt:else>
		<form method="post" action="&mvte:global:sessionurl;Screen=BASK" name="add" id="purchase-form">
	</mvt:if>
		<input type="hidden" name="Session_ID" value="&mvt:global:session_id;" />
                <input type="hidden" name="Action" value="ADPR" />
                <input type="hidden" name="Store_Code" value="&mvte:store:code;" />
                <input type="hidden" name="Product_Code" value="&mvte:product:code;" />
		<input type="hidden" name="Quantity" value="&mvt:global:basket_line_qty;" />
		<mvt:item name="product_attributes" param="product:id" />
                <div class="form-row">
                    <div id="js-purchase-message" class="message message-warning purchase-message"></div>
                </div>
	</form>
	<div id="loading"></div>
	<mvt:if expr="g.secure EQ 1">
		<form method="post" action="&mvte:global:secure_sessionurl;Screen=BASK" target="_parent" id="remove-form">
	<mvt:else>
		<form method="post" action="&mvte:global:sessionurl;Screen=BASK" target="_parent" id="remove-form">
	</mvt:if>
		<input type="hidden" name="Session_ID" value="&mvt:global:session_id;" />
		<input type="hidden" name="Action" value="RPRD" />
		<input type="hidden" name="Store_Code" value="&mvte:store:code;" />
 		<input type="hidden" name="Basket_Line" value="&mvt:global:basket_line;" />
	</form>
</body>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>window.jQuery || document.write(unescape('%3Cscript src="../js/jquery.min.js"%3E%3C/script%3E'))</script>
<script src="../js/editable_attributes.js?v=7"></script>
</html>
$(document).ready(function () {
	// ---- AJAX Add To Cart ---- //
		function addToCart () {
			$('#purchase-form :input').on('change', function (e) {
				var purchaseForm = $('#purchase-form');
				$('#loading').html('Loading...');
				// Check the form is not currently submitting
				if (purchaseForm.data('formstatus') !== 'submitting') {
					// Set up variables
					var form = purchaseForm,
						formData = form.serialize(),
						randomNo = Math.ceil(Math.random() * 1000000), // IE Hack: Creating random number to refresh ajax call
						formUrl = form.attr('action'),
						formMethod = form.attr('method'),
						responseMessage = $('#js-purchase-message'),
						processingImage = $('#js-processing-purchase'), //need to set
						purchaseButton = $(this),
						purchaseButtonText = purchaseButton.val();
					
					if (/\?/.test(formUrl)) {
						formUrl = formUrl + '&v=' + randomNo;
					}
					else {
						formUrl = formUrl + '?v=' + randomNo;
					};

					// Add status data to form
					form.data('formstatus', 'submitting');
					
					// Show processing message
					processingImage.show();
					//purchaseButton.toggleDisabled().val('Processing...');
					responseMessage.html('').hide();
					
					// Send data to server for validation
					$.ajax({
						url: formUrl,
						type: formMethod,
						data: formData,
						success: function(data, textStatus, jqXHR) {
							if (data.search(/id="BASK"/i) != -1) {

								$('#remove-form').submit();
								
							}
							else if(data.search(/id="PATR"/i) != -1) {
								$('#loading').html(' ');
								var missingAttrs = [];
								form.find('.required').each(function () {
									missingAttrs.push(' ' + $(this).attr('title'));
								});
								responseMessage.html('All <em class="red">Required</em> options have not been selected.<br />Please review the following options: <span class="red">' + missingAttrs + '</span>.').fadeIn().delay(5000).fadeOut();
							}
							else if(data.search(/id="PLMT"/i) != -1) {
								$('#loading').html(' ');
								responseMessage.html('We do not have enough of the item you have selected.<br />Please adjust your quantity.').fadeIn().delay(3000).fadeOut();
							}
							else if(data.search(/id="POUT"/i) != -1) {
								$('#loading').html(' ');
								responseMessage.html('The item you have selected is out of stock.<br />Please review your options or check back later.').fadeIn().delay(3000).fadeOut(); 
							}
							else {
								$('#loading').html('');
								responseMessage.html('Please review options.').fadeIn().delay(3000).fadeOut();
							};
							
							// Hide processing message and reset formstatus
							processingImage.hide();
							//purchaseButton.toggleDisabled().val(purchaseButtonText);
							form.data('formstatus', 'idle');
						},
						error: function (jqXHR, textStatus, errorThrown) {
						}
					});
				};
				// Prevent form from submitting
				e.preventDefault();
			});
		};
		var addToCart = new addToCart;
});
<mvt:if expr="ISNULL l.settings:item:options">
  <mvt:do file="g.Module_Library_DB" name="l.product_attributes" value="AttributeList_Load_Product(l.settings:item:product:id, l.settings:item:attributes)" />
  <mvt:if expr="l.settings:item:attributes">
    <mvt:foreach iterator="attribute" array="item:attributes">
      <mvt:if expr="l.settings:attribute:required EQ 1">
        <mvt:assign name="l.show_select_options" value="1" />
      </mvt:if>
    </mvt:foreach>
  </mvt:if>
  <mvt:if expr="l.show_select_options">
    <iframe src="&mvt:global:secure_sessionurl;Screen=PROD&Product_Code=&mvt:item:product:code;&basket_line=&mvt:item:line_id;&basket_line_qty=&mvt:item:quantity;" style="border:0;max-width:100%;"></iframe>
  </mvt:if>
</mvt:if>
<mvt:comment>=== AT THE TOP OF THE PAGE ===</mvt:comment>
<mvt:if expr="g.basket_line GT 0">
  <mvt:item name="editable_attributes" />
  <mvt:exit />
</mvt:if>

以上是关于xml TS //选择附加产品的选项/属性。的主要内容,如果未能解决你的问题,请参考以下文章

使用产品插件选择框显示产品价格 WooCommerce

Magento:合并产品描述和添加信息选项卡

php 产品属性属性获取产品属性加载产品属性附加产品属性\

附加到 DOM 时 XML 属性变为小写

附加选项后选择问题

XML序列化具有附加属性的通用列表